Code::Blocks
User forums => General (but related to Code::Blocks) => Topic started by: MadBoat on June 12, 2015, 01:15:28 am
-
Ok, I give up, time to ask for help.
I've written a fairly simple telnet plugin for Codeblocks. I have a Linux version and a windows version of this plugin, which both seem to work when compiled natively from the same source. I'm trying to collapse both of these projects into one project so that I don't have to have seperate development environments; this means cross compiling the plugin for windows on Linux using mingw32. As an initial test, I'm trying to cross compile a stock plugin; that is, what comes out of the "create plugin wizard", in codeblocks v13-12.
Here are the wiki/forum pages I've been following:
http://forums.codeblocks.org/index.php/topic,3343.75.html
wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux
After following the instructions, and employing whatever other minor fixes google can dig up for me, this is the command line I've generated.
Compiler Call
i586-mingw32msvc-g++ -ansi -g
##generated from compiler build option `pkg-config --cflags codeblocks`
-I/usr/local/include/codeblocks
-I/usr/local/include/codeblocks/tinyxml
-I/usr/local/include/codeblocks/scripting/include
-I/usr/local/include/codeblocks/scripting/bindings
-I/usr/local/include/codeblocks/scripting/sqplus
-I/usr/local/include/codeblocks/wxscintilla/include
##generated from compiler build option `/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/wx-config --cflags --host=i586-mingw32msvc --static`
-I/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/wx/include/i586-mingw32msvc-msw-unicode-release-static-2.8
-I/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/include
-I/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/contrib/include
##explicitly listed, or listed in global compiler settings
-D__WXMSW__ -mthreads -U__STRICT_ANSI__ -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__
-I/usr/i586-mingw32msvc/include
-c
/home/micron/pico_projects/codeblocks/source/bullshitprojects/bullshitCrossCompilePlugin2/BullshitCrosscompilePlugin2.cpp -o .objs/BullshitCrosscompilePlugin2.o
Linker
i586-mingw32msvc-g++ -shared .objs/BullshitCrosscompilePlugin2.o -o BullshitCrosscompilePlugin2.dll
##generated from linker build option `/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/wx-config --libs --host=i586-mingw32msvc --static`
-L/usr/i586-mingw32msvc/lib
-L/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib -mthreads -Wl,--subsystem,windows -mwindows
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_richtext-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_aui-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_xrc-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_qa-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_html-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_adv-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_mswu_core-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_baseu_xml-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_baseu_net-2.8-i586-mingw32msvc.a
/home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile/lib/libwx_baseu-2.8-i586-mingw32msvc.a
-lwxregexu-2.8-i586-mingw32msvc -lwxexpat-2.8-i586-mingw32msvc -lwxtiff-2.8-i586-mingw32msvc -lwxjpeg-2.8-i586-mingw32msvc -lwxpng-2.8-i586-mingw32msvc -lwxzlib-2.8-i586-mingw32msvc
-lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32
##generated from linker build option`pkg-config --libs codeblocks`
[b]-L/usr/local/lib -lcodeblocks[/b]
##listed in global linker settings
-lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid
The /home/micron/pico_projects/codeblocks/wxWidgets-2.8.12_windows_crossCompile directory is where I've installed a cross compiled wxWidgets... I skipped the install step of that installation so that it wouldn't conflict with my natively compiled widgets installation. As such, I call a local wx-config rather than the system wx-config.
Having done all that, I get the following error when attempting a compile
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lcodeblocks
The mingw linker is looking for libcodeblocks.a; /usr/local/lib includes copies of libcodeblocks.so and libcodeblocks.la, but not libcodeblocks.a... I can manually specify a directory with libcodeblocks.a (built via ./configure --enable-static)... if I do that, these are the errors I get;
.objs/BullshitCrosscompilePlugin2.o: In function `BullshitCrosscompilePlugin2':
/home/micron/pico_projects/codeblocks/source/bullshitprojects/bullshitCrossCompilePlugin2/BullshitCrosscompilePlugin2.cpp:13: undefined reference to `__imp___ZN12cbToolPluginC2Ev'
/home/micron/pico_projects/codeblocks/source/bullshitprojects/bullshitCrossCompilePlugin2/BullshitCrosscompilePlugin2.cpp:18: undefined reference to `__imp___ZN7Manager12LoadResourceERK8wxString'
/home/micron/pico_projects/codeblocks/source/bullshitprojects/bullshitCrossCompilePlugin2/BullshitCrosscompilePlugin2.cpp:13: undefined reference to `__imp___ZN12cbToolPluginC2Ev'
/home/micron/pico_projects/codeblocks/source/bullshitprojects/bullshitCrossCompilePlugin2/BullshitCrosscompilePlugin2.cpp:18: undefined reference to `__imp___ZN7Manager12LoadResourceERK8wxString'
.objs/BullshitCrosscompilePlugin2.o: In function `PluginRegistrant':
/usr/local/include/codeblocks/cbplugin.h:901: undefined reference to `__imp___ZN7Manager3GetEv'
/usr/local/include/codeblocks/cbplugin.h:901: undefined reference to `__imp___ZNK7Manager16GetPluginManagerEv'
/usr/local/include/codeblocks/cbplugin.h:901: undefined reference to `__imp___ZN13PluginManager14RegisterPluginERK8wxStringPFP8cbPluginvEPFvS4_EPFvPiS9_S9_E'
.objs/BullshitCrosscompilePlugin2.o: In function `~cbToolPlugin':
/usr/local/include/codeblocks/cbplugin.h:665: undefined reference to `__imp___ZTV12cbToolPlugin'
/usr/local/include/codeblocks/cbplugin.h:665: undefined reference to `__imp___ZN8cbPluginD2Ev'
.objs/BullshitCrosscompilePlugin2.o: In function `_Z17NotifyMissingFileRK8wxString':
/usr/local/include/codeblocks/globals.h:329: undefined reference to `__imp___Z12cbMessageBoxRK8wxStringS1_iP8wxWindowii'
.objs/BullshitCrosscompilePlugin2.o:BullshitCrosscompilePlugin2.cpp:(.rdata$_ZTV27BullshitCrosscompilePlugin2[vtable for BullshitCrosscompilePlugin2]+0x78): undefined reference to `cbPlugin::NotImplemented(wxString const&) const'
collect2: ld returned 1 exit status
At this point I'm stuck. These look like mangled names to me, but libcodeblocks.a does contain references to cbToolPlugin at least... I can guess that libcodeblocks.a doesn't create entry points with mangled names, but I don't know why my application would expect mangled names. I'm also not cross compiling libcodeblocks.a, and it seems like that is unlikely to work if libcodeblocks.a is referencing linux libraries, but I can't find instructions on how to cross compile the codeblocks executable... simply following the style described for cross compiling wxWidgets did not work.
Can someone point me at a guide for cross compiling the codeblocks executable? Or else, tell me what other thing I'm doing wrong?
-
When compiling for Windows the defines needs to be correct for the import/export of DLLs.
You error seems to be related to that.
Edit: When building an CB Plugin BUILDING_PLUGIN must be defined
Tim S.
-
You can not use linux binaries of codeblocks (and itslibs) to cross-compile a plugin for windows.
How should this work ?
You can try to cross-compile C::B, but I doubt you will be able to use the plugin with natively compiled (windows) builds of Code::Blocks.
-
You should probably not use `pkg-config --libs codeblocks`. What it does is return linking flags needed to link a plugin to the linux version of codeblocks you have installed.
So you either has to use manual paths/options to link to libcodeblocks from the windows version.
Or provide a custom version of the codeblocks.pc file and also override the PKG_CONFIG_PATH, so it can be correctly found.
But as Jens said it will be tough to make matching binaries, because of the C++ ABI and probably different compilers.
-
You can not use linux binaries of codeblocks (and itslibs) to cross-compile a plugin for windows.
How should this work ?
You can try to cross-compile C::B, but I doubt you will be able to use the plugin with natively compiled (windows) builds of Code::Blocks.
I agree the binary is NOT likely to work; but, I was thinking he just wanted to make sure it compiled and linked; not that he could use the binary.
I was just trying to get CB to cross compile on Linux for that reason two weeks ago.
I decided it was easier to dual boot.
Tim S.
-
You can try to cross-compile C::B, but I doubt you will be able to use the plugin with natively compiled (windows) builds of Code::Blocks.
Yes, this seems obvious in retrospect. I still can't actually perform the cross compile. Perhaps it would be easier to dig up a pre-cross compiled version of libcodeblocks.a? Is it possible to repackage a windows library as a linux library?
I agree the binary is NOT likely to work; but, I was thinking he just wanted to make sure it compiled and linked; not that he could use the binary.
I was just trying to get CB to cross compile on Linux for that reason two weeks ago.
I decided it was easier to dual boot.
Tim S.
No, I would need it to run as well. I'm guessing you also looked and couldn't find instructions to cross compile codeblocks?
-
No, I would need it to run as well. I'm guessing you also looked and couldn't find instructions to cross compile codeblocks?
I found the old directions and used them to cross compile codeblocks.
Edit: I did NOT try to follow them exactly because they were too old; I had to change a lot to get the cross compile to work.
It took a few hours of effort.
I did NOT try to build the Contrib Plugins using CB projects.
Are you trying the configure/make route or CB project route?
If the CB Project route, I might still have a copy of the main CB project that you can adapt.
I needed to learn how to use WINE to run it.
I did my work on Debian 8.0; so, it differs from your work.
Tim S.
-
You might wish to read this link. You will have to adapt the directions to using a cross compiler.
http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build (http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build)
Tim S.
-
I found the old directions and used them to cross compile codeblocks.
Edit: I did NOT try to follow them exactly because they were too old; I had to change a lot to get the cross compile to work.
It took a few hours of effort.
If you have directions, even old ones, for cross compiling code blocks, I'd love to see them.
I did NOT try to build the Contrib Plugins using CB projects.
Are you trying the configure/make route or CB project route?
Not sure what you're asking. I am building my plugin as a CB project. I am trying to cross compile codeblocks via the configure/make method.
If the CB Project route, I might still have a copy of the main CB project that you can adapt.
I needed to learn how to use WINE to run it.
If you've got it on hand, sure. Please don't spend more than 5 minutes screwing around on this though... I don't want to send anyone on a wild goose chase, and I can still resort to a two-system solution if I cant get this to work.
-
Link to the project; but, it will NOT help do anything but compile Code::Blocks Under Linux.
https://github.com/stahta01/codeblocks-svn2git/blob/devel/cross_compile/src/CodeBlocks_wx28-win32.cbp (https://github.com/stahta01/codeblocks-svn2git/blob/devel/cross_compile/src/CodeBlocks_wx28-win32.cbp)
I made the cross compiler to be named gcc-win32.
I used the MinGW64 32 bit version of GCC on Debian.
I suggest you read the second third post of mine because the linking to DLL method is what you really need to do!!
Edit2: Quoted that post below
You might wish to read this link. You will have to adapt the directions to using a cross compiler.
http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build (http://wiki.codeblocks.org/index.php?title=Linking_the_plugin_to_a_Nightly_Build)
Tim S.
Tim S.