Code::Blocks

User forums => Using Code::Blocks => Topic started by: visualphoenix on June 16, 2006, 01:52:25 am

Title: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on June 16, 2006, 01:52:25 am
Hey everyone! Today I managed to finish figuring out how to set up the build options for cross compiling, debugging and running windows executables for projects built with codeblocks using linux... As such, I decided it was time to sign up for the c::b forums and post a howto in case anyone else was interested in knowing what I did...

The following is how I did this on Ubuntu 'Dapper Drake' Linux:

Step 1:

Install MingW32 for linux
Code: [Select]
# sudo apt-get install mingw32

Step 2:

Settings->Compiler and debugger settings
Code: [Select]
Select GNU GCC Compiler and click the Copy button.
 Name this: MingW32 Compiler

Step 3:

Click the Compiler tab and then click the #defines tab.
 Add the following:
Code: [Select]
  WINVER=0x0400
  __WIN95__
  __GNUWIN32__
  STRICT
  HAVE_W32API_H
  __WXMSW__
  __WINDOWS__

Click the Linker tab and the following under "Other Linker Options":
Code: [Select]
-lstdc++
-lgcc
-lodbc32
-lwsock32
-lwinspool
-lwinmm
-lshell32
-lcomctl32
-lctl3d32
-lodbc32
-ladvapi32
-lodbc32
-lwsock32
-lopengl32
-lglu32
-lole32
-loleaut32
-luuid
*Note: Not all of these are REQUIRED... As I have been recently messing with compiling apps for windows with ogl and dx9 support I have realized that there are some additions I have needed to add here... I will update accordingly when I know more.

Step 4:

Click the Directories tab and the Compiler tab.
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

Click the Directories tab and the Linker tab:
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/lib

Click the Directories tab and the Resource Compiler tab:
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

Step 5:

Click the Programs tab:
Code: [Select]
C compiler: i586-mingw32msvc-gcc
 C++ compiler: i586-mingw32msvc-g++
 Linker for dynamic libs: i586-mingw32msvc-g++
 Linker for static libs: i586-mingw32msvc-ar
 Debugger: i586-mingw32msvc-gdb    **** MORE ON THIS LATER ****

Click OK and save your changes.

Step 6:

Ubuntu's mingw32 package and from what I can tell, MingW32 in general doesnt really have a solid gdb option for debugging natively in linux so we're going to work around this using wine and mingw32's latest insight build for windows

Install Wine
Code: [Select]
# sudo apt-get install wine

Step 7:

Download Insight here:
Code: [Select]
http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82725&release_id=371590

Step 8:

Once you download insight.exe, extract the archive using wine:
Code: [Select]
wine insight.exe
I extracted this to my desktop

Step 9:

Move the insight folder to /opt

the path should now look like
Code: [Select]
/opt/insight/bin/gdb.exe
Step 10:

create a shell script in /usr/bin:

(note: shell scripts should start with a hash (#) bang (!), ie: "# ! / bin / sh " [with no spaces] but when I add that the forum post tanks)
Code: [Select]
# sudo gedit /usr/bin/i586-mingw32msvc-gdb
and add the following:
Code: [Select]
wine /opt/insight/bin/gdb.exe "[email protected]"

Save the file and quit gedit

Step 11:
Code: [Select]
# sudo chmod +x /usr/bin/i586-mingw32msvc-gdb
Now we have a way to execute the windows version of mingw32's gdb for windows in linux using our shell script wrapper

Step 12:

Create a new console application project in Codeblocks...

Using the wizard select the MingW32 Compiler option.

Step 13:

Right click the project and go to properties. Click the Targets tab and set the Output Filename to be whatever you want with a .exe file extension. Make sure the Type is a Console Application.

Step 14:

When I reached this step, compiled and tried to run my application I realized that for some reason codeblocks was trying to execute my .exe through /usr/bin/wine-auto (which I do not have)... So I created a simlink to wine:
Code: [Select]
# sudo ln -s /usr/bin/wine /usr/bin/wine-auto

Step 15:

Hit F9 in codeblocks and the hello world application runs!! YAY!

Set a breakpoint on line 5 and hit F8 and the application breaks in the debugger!! Woot!

Now you can successfully compile, execute, and debug windows applications in linux using codeblocks!!!

While this worked perfectly for me on my set up please try this yourself and let me know if I can update this howto in any way.

A special thanks to all the codeblocks developers... Code::Blocks is the most awesome IDE for linux I've ever used.

*Update: Added note about libraries
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: mandrav on June 16, 2006, 09:23:20 am
Impressive and detailed HOWTO! Thanks :)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: killerbot on June 16, 2006, 10:49:42 am
Quote
  __WIN95__

Is this needed for every windows version (say win XP sp2) ??
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on June 16, 2006, 11:20:18 am
Well, I'd say this should definitely go into the WiKi. Great article!
If there are no objections, visualphoenix: Would you do that?
With regards, Morten.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Michael on June 16, 2006, 03:42:32 pm
Hello,

Interesting really :). Good job.

Anyway, there was also my lost post... :)

http://forums.codeblocks.org/index.php?topic=2688.0

Best wishes,
Michael
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on June 16, 2006, 05:52:35 pm
Hello,

Interesting really :). Good job.

Anyway, there was also my lost post... :)

http://forums.codeblocks.org/index.php?topic=2688.0

Best wishes,
Michael


Yea, I want to say thank you to you as well Michael for the links. When I was originally trying to figure out how to do this they provided a couple of clues.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on June 16, 2006, 05:54:28 pm
Well, I'd say this should definitely go into the WiKi. Great article!
If there are no objections, visualphoenix: Would you do that?
With regards, Morten.

Hey Morten, Thanks for the comment! I was thinking of adding it to the wiki rightoff under Cross_Compiling but I figured I'd test the waters here to find out how it was recieved. I'll go ahead and add it. Once again thanks to all the dev's for such a kickin' IDE.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on June 16, 2006, 05:56:47 pm
Quote
  __WIN95__

Is this needed for every windows version (say win XP sp2) ??

Possibly although YMMV. I will need more time to look into this.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: uFo-Z on June 25, 2006, 11:38:02 am
well, i created also a howto for Cross Compiling. I did not know that this howto exists and maybe we could bring together what belongs togehter. it is not that detailed like yours, but there are some pictures we could use.


http://wiki.codeblocks.org/index.php?title=Code::Blocks_and_Cross_Compilers

I also planed, are let me better say thougt about to start with a Cross Compiler plugin for C::B. The idea is to make a tool wich would setup some Paths, and vars in the Compiler and Debugger Tab, and also could download precompiled developer libs like SDL, ncurses ... to use them with the Cross Compiler. Then everybody who wants create Win executable under Linux would have an easier way.
Let me know if there are interesstes for such a plugin.  Atm i have exams so  i would start in some weeks, and maybe somone else would/could help me a litle bit with that thing.
 
bye bye, and thank you for C::B
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: tiger on November 07, 2006, 09:04:26 am
Step 14:

When I reached this step, compiled and tried to run my application I realized that for some reason codeblocks was trying to execute my .exe through /usr/bin/wine-auto (which I do not have)... So I created a simlink to wine:
Code: [Select]
# sudo ln -s /usr/bin/wine /usr/bin/wine-auto

Step 15:

Hit F9 in codeblocks and the hello world application runs!! YAY!

Set a breakpoint on line 5 and hit F8 and the application breaks in the debugger!! Woot!

Now you can successfully compile, execute, and debug windows applications in linux using codeblocks!!!

While this worked perfectly for me on my set up please try this yourself and let me know if I can update this howto in any way.

A special thanks to all the codeblocks developers... Code::Blocks is the most awesome IDE for linux I've ever used.

*Update: Added note about libraries

When pressing F9 I can't debug the program, I got this error:
Code: [Select]
run-detectors: unable to find an interpreter for /home...../hello.exe
I think this is the reason:
Code: [Select]
Settings->Environment->General settings->Terminal to launch console: xterm -T $TITLE -e
But I don't know how to make the debugger work.
?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on November 07, 2006, 07:09:39 pm
I'll look into your problem tonight. It has been a while since I used this setup.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: thomas on November 07, 2006, 08:47:31 pm
Talking of cross-compiling, wouldn't that possibly be a less painful way of building MinGW/gcc 4.x?

The MSYS way is so darn painful, it never works satisfactory, and it takes ages to even run ./configure in every subfolder, not even thinking about actually compiling anything.

Have you ever tried doing a cross-compile of MinGW?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: visualphoenix on November 07, 2006, 10:46:16 pm
ummm... the howto is a setup of how to use codeblocks to do a cross compile with mingw... hes only having problems running the program through wine and using the wine debugger with codeblocks.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: koen on November 18, 2006, 07:28:28 pm
After installing MingW32, how do I proceed to install the required wxWidgets header files, so I can compile wxWidgets projects? I think I'm just a bit lost on where to put the files. Did anyone manage to do this and is he/she willing to share some information?

Thanks!
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Pecan on November 18, 2006, 07:35:30 pm
After installing MingW32, how do I proceed to install the required wxWidgets header files, so I can compile wxWidgets projects? I think I'm just a bit lost on where to put the files. Did anyone manage to do this and is he/she willing to share some information?

Thanks!
   //-- Wiki Index
       CodeBlocks Wiki Index (http://wiki.codeblocks.org/index.php?title=Special:Allpages)
   //-- Wiki Main Page
     CodeBlocks Wiki Main Page (http://wiki.codeblocks.org/index.php?title=Main_Page)

Read Topic:
Installing Code::Blocks from source on Windows or Linux or Fedora or ....
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: koen on November 18, 2006, 07:45:41 pm
After installing MingW32, how do I proceed to install the required wxWidgets header files, so I can compile wxWidgets projects? I think I'm just a bit lost on where to put the files. Did anyone manage to do this and is he/she willing to share some information?
Read Topic:
Installing Code::Blocks from source on Windows or Linux or Fedora or ....

I browsed through those pages, but I couldn't find what I was looking for. Maybe my problem statement wasn't clear enough. Let me try to elaborate:

I have installed C::B on Linux and I am able to compile/build/run wxWidgets projects on Linux. Now I would like to cross-compile my program to Windows. As far as I understand, I need MingW32 to do the actual cross-compilations, so I installed that first. However, when I try to cross-compile my program, I get errors because wxWidgets-msw files are missing (the first one it complains about is wx/msw/chkconf.h), which makes sense. So I guess I have to install those, but I'm not sure where to put them or what would be the best way to do this.

The page you sent me to seems to be about installing C::B itself, but I've already got that running (on Linux).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Pecan on November 18, 2006, 11:47:39 pm
Sorry that I misunderstood.

I am unaware that wxWidgets for windows can be installed on Linux and then used to compile a windows pgm.

Maybe someone familiar with Wine or some such can help.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: koen on November 19, 2006, 01:52:59 am
Sorry that I misunderstood.
I am unaware that wxWidgets for windows can be installed on Linux and then used to compile a windows pgm.
Maybe someone familiar with Wine or some such can help.

I don't think Wine should be necessary. Of course, for testing and debugging it may be used, but for cross-compiling, one shouldn't need Wine.

I found a page on cross-compiling wxWidgets under Linux (http://www.wxwidgets.org/wiki/index.php/Cross-Compiling_Under_Linux (http://www.wxwidgets.org/wiki/index.php/Cross-Compiling_Under_Linux)), which is supposed to result in a set of wxMSW header/object files. I ran configure, make and make install, and that seems to have worked out all OK. I'll check whether it has produced something useful later.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: FreeSouth on May 29, 2007, 10:35:40 am
Thank you ,,,,very useful to me~
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Morphius Faydal on October 19, 2007, 06:25:16 pm
Now if only the Gentoo ebuilds of MinGW weren't broken...

Also; on a stylistic note; MingW32 isn't the proper name for the cross compiler.. MinGW is the "official" naming, standing for "Minimal GNU for Windows".. Min.. G.. W. :)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: alchemist on October 20, 2007, 10:41:10 am
Now if only the Gentoo ebuilds of MinGW weren't broken...

Also; on a stylistic note; MingW32 isn't the proper name for the cross compiler.. MinGW is the "official" naming, standing for "Minimal GNU for Windows".. Min.. G.. W. :)

Hello, what did you tried ? crossdev ?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Morphius Faydal on October 20, 2007, 10:46:10 am
Now if only the Gentoo ebuilds of MinGW weren't broken...

Also; on a stylistic note; MingW32 isn't the proper name for the cross compiler.. MinGW is the "official" naming, standing for "Minimal GNU for Windows".. Min.. G.. W. :)

Hello, what did you tried ? crossdev ?

The two actual ebuilds for MinGW in Portage both have notes in them stating that they're broken.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: alchemist on October 20, 2007, 11:01:44 am
Last year I tried crossdev with no success. I am emerging it now and testing it.

I think we could only use the non-ebuild cross-building scripts ;)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: alchemist on October 20, 2007, 11:12:13 am
OK, after running
Code: [Select]
crossdev --target mingw32I got
Code: [Select]
#mingw32-g++ --version
mingw32-g++ (GCC) 4.2.2 (Gentoo 4.2.2 p1.0)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Next step : cross-build binutils, gcc, w32api et wxMSW ;)

EDIT: done (i'm in 64 bits)
Code: [Select]
USE="-* contrib unicode xrc" ROOT=/data/mingw32-build/ CHOST=mingw32 CBUILD="x86_64-pc-linux-gnu" emerge -1av --nodeps sys-devel/binutils sys-devel/gcc w32api make wxGTK
but cross-compilation of code::blocks through emereg didn't worked:
Code: [Select]
checking for wx-config... /usr/lib64/wx/config/gtk2-unicode-release-2.8
checking for wxWidgets version >= 2.6.0... no

I will take a look later.

Moreover, emerge installed binutils and gcc with too many symlinks I'll have to manually adjust.

Maybe I'll use the standard "./configure && make && make install" procedures.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: wvdakker on November 19, 2007, 01:50:42 pm
I have installed CodeBlocks, Mingw and wxWidgets in Linux.
Transfered a project created in Windows to the Linux env.
The DLL-files are build ok but there are no library files (.a) created.
The option 'Create import library' is enabled, but nothing there.

Any clue??

gr,
Willem
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: mandrav on November 19, 2007, 01:59:43 pm
I have installed CodeBlocks, Mingw and wxWidgets in Linux.
Transfered a project created in Windows to the Linux env.
The DLL-files are build ok but there are no library files (.a) created.
The option 'Create import library' is enabled, but nothing there.

Any clue??

gr,
Willem

There are no "import libraries" in linux. You create shared objects (.so, equivalent to .dll) or static libraries (.a).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: wvdakker on November 19, 2007, 04:17:55 pm

There are no "import libraries" in linux. You create shared objects (.so, equivalent to .dll) or static libraries (.a).

If I am crosscompiling for windows then libs must be available... or ....??
Otherwise how do I link dll's to other dll's or exe files.

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: wvdakker on November 23, 2007, 11:22:41 am
Found the problem :)

These options where missing in the MingW32 Cross Compiler settings.
-Wl,--output-def=$def_output -Wl,--out-implib=$static_output -Wl,--dll

Adding them solved the problem.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: szurilo on February 29, 2008, 02:55:39 pm
Hi!
I installed mingw32 and set up the parameters of the GNU GCC compiler.
I realized the i586-mingw32msvc-gcc g++ etc. files are not in the /usr directory but the /usr/bin.
So i set the correct paths and files and set this copy of the compiler as default as this thread write them.
After this, I created a new empty console application project and a new build target.
I don't know whether is a must or not to set the platform to 'Windows' or i can leave it to 'All'.
Anyway i tried both. Actually i am really confused about the Project Settings tab, because its also consists a Platform option. :shock:
So i checked my Build target Files and click OK.
I selected my build target in the Build menu and push the magic Build button.
The output can be different according to i set the platforms type in the Project/Properties menu.
If i set it 'Windows', i got this message and no output created:
"proba" does not support the current platform. Skipping...
Nothing to be done.
If i leave the platform type on 'All' my project is builded and i got one output file without 'exe' extension and i cant run it with wine bec. its a Linux file, i guess.
So what is the problem?
CB 4893 nightly; wxWidgets 2.8.7; distro: Debian;

Szurilo
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: HalfNote5 on April 10, 2008, 06:43:02 pm
Thanks!

I'm an old C++ programmer, but new to Code::Blocks.  It's great to be able to write a C++ program, and without moving it back and forth, be able to write it on my linux lappy, and compile it for all with Win32 machines of the clients that are buying it.  ; )


Many thanks!
You're  a kind person to detail the steps for the rest of us.


Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 09, 2008, 08:59:11 pm
I want to cross compile my wxwidgets application but there is nothing in this (good howto) about it, so I wanted to add that to this howto (and update it too).

By the way, I follow the howto but when I tried to debug the sample aplication (on the last step) I have the following output on the Debbuger window:

Code: [Select]
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /home/cesar/CodeBlocks/probaMinGW32/
Adding source dir: /home/cesar/CodeBlocks/probaMinGW32/
Adding file: bin/Debug_L64/probaMinGW32.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.3
Error creating process Z:\home\cesar\CodeBlocks\probaMinGW32/bin/Debug_L64/probaMinGW32.exe, (error 32)

And, obviously, if I try to continue debuging (Next Instruction, Step into...) I obtain an error:
Code: [Select]
Continuing...
The program is not being run.
Debugger finished with status 1

Really, I do not want to debug Windows applications under linux, just compile them, but I do not want to post a buggy howto, or leave this buggy (actually) now that I find it for the users who will need it in the near future. So, if someone can help me, it would be appreciated.

I am using:
-Ubuntu 8.04 x86_64
-Code::Blocks svn5177
-MinGW32 4.2.1
-Insight 6.3
-Wine 1.0
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 09, 2008, 09:41:09 pm
Have you read my wiki-article: http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux) ?

There you can also find some thoughts about debugging windows-applications from within C::B compiled for linux.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 10, 2008, 12:27:17 pm
Well, I have followed all the links I found about it (in this forum, in codeblocks wiki and in wxWidgets wiki) but I miss yours. :oops:

So I go and try it just now. Also I found some problems with the wxWidgets for MSW (with the repository of http://apt.wxwidgets.org/ and build from source), so let's try you wiki!!! :)

P.D.: And my nightly comes from your repository, so thank you for all. :wink:
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 10, 2008, 01:30:04 pm
Well, when I added the wxWidgets repository I use it as "gutsy-wx" instead "hardy-wx" because at that time wxWidgets have not an hardy repository, so I try to update it before trying your wiki-article and now it works.

I follow your article and now I can cross compile correctly wxWidgets applications. I have solved one modifying <wx/chkconf.h> which is best solved using
Code: [Select]
--prefix=/usr/i586-mingw32msvc as you do. The other error (wxUSE_DATAOBJ not defined) have been solved by any of the steps, but I don't what. The fact is that it works, so THANKS.

When I tried the debugger (insight) it reported the same errors, so I download the recent gdb as your wiki says (6.8-rc) and now the debugger don't crash, but it report some errors (with the sample console application as suggested by this topic howto):
Code: [Select]
Error while mapping shared library sections:
Error while reading shared library symbols:
Error while mapping shared library sections:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while mapping shared library sections:
Error while reading shared library symbols:
Error while reading shared library symbols:
Error while reading shared library symbols:

With only this little inconvenient, I can say that this howto is well superceded by your wiki-article. Thank you ;)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 10, 2008, 02:11:24 pm
Eps, too early it seems to be finished.

I have confused the build target, the cross compiler one don't work. I'm confused about a section of your article: "Fixing build options".
Code: [Select]
In the Build options of the project you have to move `wx-config --cflags` from the global Compiler settings -> Other options to the one for the standard build targets (Debug and Release).

`wx-config --cflags`??? I didn't have that.

Code: [Select]
The appropriate calls to wx-config for the WinRelease must have the parameter: --host=i586-mingw32msvc included and should have the parameter --static set also.

If I understand you, I have to go to the Build options of WinRelease-target and then to Compiler settings -> Other options and add:
Code: [Select]
`wx-config --host=i586-mingw32msvc --static --prefix=/usr/i586-mingw32msvc`
If I do that I get this Build Messages:
Code: [Select]
/usr/include/wx-2.8/wx/platform.h|540|error: wx/msw/libraries.h: No such file or directory|
/usr/include/wx-2.8/wx/defs.h|2820|error: conflicting declaration ‘typedef struct GtkWidget* WXWidget’|
/usr/include/wx-2.8/wx/defs.h|2611|error: ‘WXWidget’ has a previous declaration as ‘typedef void* WXWidget’|
/usr/include/wx-2.8/wx/string.h|827|error: ‘wxChar& wxString::operator[](unsigned int)’ cannot be overloaded|
/usr/include/wx-2.8/wx/string.h|824|error: with ‘wxChar& wxString::operator[](size_t)’|
/usr/include/wx-2.8/wx/hashmap.h||In member function ‘wxLongToLongHashMap_wxImplementation_HashTable::Node** wxLongToLongHashMap_wxImplementation_HashTable::GetNodePtr(const long int&) const’:|
/usr/include/wx-2.8/wx/hashmap.h|714|warning: dereferencing type-punned pointer will break strict-aliasing rules|
/usr/include/wx-2.8/wx/clntdata.h||In member function ‘wxShadowObjectMethods_wxImplementation_HashTable::Node** wxShadowObjectMethods_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:|
/usr/include/wx-2.8/wx/clntdata.h|20|warning: dereferencing type-punned pointer will break strict-aliasing rules|
/usr/include/wx-2.8/wx/clntdata.h||In member function ‘wxShadowObjectFields_wxImplementation_HashTable::Node** wxShadowObjectFields_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:|
/usr/include/wx-2.8/wx/clntdata.h|25|warning: dereferencing type-punned pointer will break strict-aliasing rules|
/usr/include/wx-2.8/wx/gdicmn.h||In member function ‘wxStringToColourHashMap_wxImplementation_HashTable::Node** wxStringToColourHashMap_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:|
/usr/include/wx-2.8/wx/gdicmn.h|544|warning: dereferencing type-punned pointer will break strict-aliasing rules|
/usr/include/wx-2.8/wx/filefn.h|398|error: zero width for bit-field ‘wxAssert_399::BadFileSizeType’|
/usr/include/wx-2.8/wx/image.h||In member function ‘wxImageHistogramBase_wxImplementation_HashTable::Node** wxImageHistogramBase_wxImplementation_HashTable::GetNodePtr(const long unsigned int&) const’:|
/usr/include/wx-2.8/wx/image.h|136|warning: dereferencing type-punned pointer will break strict-aliasing rules|
||=== Build finished: 6 errors, 5 warnings ===|

Firstly, I understand you that I have to put to Compiler settings -> Other options:
Code: [Select]
--host=i586-mingw32msvc --static --prefix=/usr/i586-mingw32msvcbut I obtain in the Build log:
Code: [Select]
Compiling: probaWxMinGWApp.cpp
i586-mingw32msvc-g++: unrecognized option '-pthread'
cc1plus: error: unrecognized command line option "-fhost=i586-mingw32msvc"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
so I try the other option.

What I am doing wrong?

This afternoon I will try to compile wxWidgets myself (one more time) if it fixes something.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 10, 2008, 02:36:23 pm
All the "wx-config"-stuff is only needed if you cross-compile with wxWidgets, it's not needed for pure console or win32-apps. If you want to use the latter, just copy a wizard-created win32-gui project from a win-box to your linux-box (you might have to fix something in properties or build options, Im not sure about that at the moment).

If you do so just start with the wxwidgets-wizard as I do in my example in the wiki.

And you need the cross-build-libs for wxWidgets, that I provide on my server. You can of course try to compile them yourself, but mine should work out of the box, if you have wxWidgets-2.8.8 installed.

You might need to install the "wx2.8-headers-msw-force-depends", if you get errors, because the "wx2.8-headers"-version from your distro, or from wxwidgets.org does not match the exact version of my "wx2.8-headers-msw".
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 10, 2008, 03:52:46 pm
I'm using wxWidgets on my application, so I need to cross compile with it.

I've created a new wxWidgets project with the wizard as you do in the wiki.

I've picked "libwxmws2.8dbg", "libwxmsw2.8dev", "wx2.8headers-msw" and "wx2.8-headers-msw-force-depends" from your repository.

I just take a look on synaptic and your wxMSW is 2.8.8.0 and my wxWidgets is 2.8.8.1 (from wxWidgets repository) so this can be the problem, as you write.

Then I try to compile wxWidgets myself with the ./configure of your wiki and obtain this:
Code: [Select]
Configured wxWidgets 2.8.8 for `i586-pc-mingw32msvc'

  Which GUI toolkit should wxWidgets use?                 msw
  Should wxWidgets be compiled into single library?       no
  Should wxWidgets be compiled in debug mode?             no
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets be compiled in Unicode mode?           yes
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.4      no
                                       wxWidgets 2.6      yes
  Which libraries should wxWidgets use?
                                       jpeg               builtin
                                       png                builtin
                                       regex              builtin
                                       tiff               builtin
                                       zlib               builtin
                                       odbc               no
                                       expat              builtin
                                       libmspack          no
                                       sdl                no

Why mine should not compile as a single library?

Well, I go to try it.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 10, 2008, 05:53:39 pm
Why mine should not compile as a single library?

I also do not use monolithic libs for my .deb's.

It was just an example-output in the wiki, but I just corrected it to show the output you get with the "./configure"-line I used as example to avoid misunderstandings.

The changes between 2.8.8.0 and 2.8.8.1 do not touch msw-builds afaik. But I will update my repo anyway to keep the version-numbering consistent.
EDIT (2.):
wxwidgets.org does not provide sources for 2.8.8.1 with msw build-tree included, that means I would have to merge  it manually, but that's a little too much work, if it's only done to keep the version-number in sync.

EDIT:
Btw: the cross-libs only depend on the "wx2.8-headers"-package, so a change to source-code for linux (except for the headerfiles perhaps) can not harm the msw-cross-libraries.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 12, 2008, 02:19:29 am
I agree with you that it is a little too much work. However, as I am going to need it, I give it another chance.

I started using wxWidgets 2.8.8.1 from wxWidgets repo and wxMSW 2.8.8.0 from your repo, I've configured Code::Blocks as your wiki-article says, using `wx-config --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --static` in Compiler settings -> Other options of the Windows build target.

I found lots of errors, mostly in wx header files, saying that it can find include file /usr/include/wx-2.8/wx/msw/include-file.h and I thinked about fix all manually, but I was lazy so I finally compile wxMSW with the following options:
Code: [Select]
./configure --host=i586-mingw32msvc --enable-unicode --build=`./config.guess` --disable-shared
That is, yours without --prefix (it installs to /usr/local) and it get to work, only a few warnings, but it compiles and runs in Windows XP. I also add the flags to compiling and linking options for the MinGW32 compiler as suggested by http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux but it seems that they are not necessary.

Then, I try cross compiling my own project and I get problems with wxPropertyGrid (the same which Code::Blocks use) for the cross build, but that is already another story.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 12, 2008, 06:20:57 am
Did you run "wx-config --list" before compiling everything new.
Are you sure everything was setup correctly and that there are not rests of former tries to compile wxWidgets on your own ?

About wxPropertyGrid:

wxPropertyGRid is not part of wxWidgets.
It's a standalone-project ( http://wxpropgrid.sourceforge.net/cgi-bin/index (http://wxpropgrid.sourceforge.net/cgi-bin/index) ).

I don't know how to set it up for cross-compiling.
Sorry.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 15, 2008, 05:59:14 pm
I've reinstalled Ubuntu (for the garbage generated with manual compiling wxWidgets) and decided to give a last chance to your wxMSW.

This time I see that I have set `wx-config --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --static` in Compiler settings -> Other options but don't in Linker Settings -> Other options. But there is no change, it continues to search include files in /usr/include/wx-2.8/wx/msw/ so it can't compile.

Then I compile wxWidgets with the same configure options as I write in the last post and it get to work right (after uninstall your wxMSW).

I know that wxPropertyGrid is not part of wxWidgets. I wrote:
Then, I try cross compiling my own project and I get problems with wxPropertyGrid (the same which Code::Blocks use) for the cross build, but that is already another story.
only as a comment. This time I've could cross compile it with my windows release.

After that (I don't know if it is related with cross-compilation, but I get this error after setting Code-Blocks and my project for cross-compiling) I get this error building with the default Debug-target (wich I don't modify at any time):

Code: [Select]
cc1plus: error: no se reconoce la opción de línea de comando "-mthreads"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

Approximate translation:

Code: [Select]
cc1plus: error: unknown command line option "-mthreads"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

This only happens when I try to build the whole project (or Rebuild), not when building changes.

Any idea?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 15, 2008, 07:19:19 pm
If you did not set -mthreads manually, it means that you use the "wx-config" of the cross-libs for the linux-build ("-mthreads" belongs to win, "-pthread" to linux).

Can you provide a sample project where the error occurs ?
If possible it would be nice if you can also send me your default.conf ("~/.codeblocks/default.conf").
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 16, 2008, 12:35:45 am
You are right.

After compiling (and installing) wxMSW, I've check the wx-config --list output and it was right.

But now, I recheck it and only obtain:

Code: [Select]
   Default config is i586-mingw32msvc-msw-unicode-release-static-2.8

Default config will be used for output

I don't know when it changed, but it changed.

I'm trying to solve it by making a symbolic link to the right wx-config:
Code: [Select]
$ sudo ln -s /usr/lib/wx/config/gtk2-unicode-release-2.8 /usr/bin/wx-configbut I obtain the same as above with wx-config --list.

In contrast, if I try /usr/lib/wx/config/gtk2-unicode-release-2.8 --list I obtain:
Code: [Select]

    Default config is gtk2-unicode-release-2.8

  Default config will be used for output

  Alternate matches:
    base-unicode-debug-2.8
    base-unicode-release-2.8
    gtk2-unicode-debug-2.8

  Also available in /usr:
    i586-mingw32msvc-msw-unicode-release-static-2.8


Even if I copy it directly, I obtain the same result, I'm confused.

I will continue with it tomorrow. I think that is time to go to wxWidgets forum.

I can provide them, but I think that it is not necessary because the cause was found.

Thanks.

EDIT:
When compiling wxWidgets without --prefix it is installed in /usr/local. So when I type wx-config --list in the terminal the system uses the one which is in /usr/local/bin. The same applies when building in Code::Blocks.

So, if I want to cross-compile under linux, I should compile all wxWidgets libraries by myself (and get it to work)... It seems that I will install Code::Blocks in windows.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 16, 2008, 10:15:07 am
If the wx-config does not list the correct entries, it's a wxWidgets install issue.
What does
Code: [Select]
update-alternatives --list wx-config show?

It should be something like:
Code: [Select]
/usr/lib/wx/config/base-unicode-release-2.8
/usr/lib/wx/config/gtk2-unicode-release-2.8
.
If not it might be that you did not install the exWidgets-dev packages correctly.
You can try to uninstall your self-compiled wxwidgets by running "make uninstall" from its source directory.
And then reinstall all wxWidgets-packages.

You should eventually purge them first.

From synaptic chose "remove completely", maybe it's not the exact text, but it should be something like this (my system uses german language).

Then install:
"libwxbase2.8-0", "libwxbase2.8-dev", "libwxgtk2.8-0", "libwxgtk2.8-dev", "wx2.8-headers", "wx2.8-i18n", "wx-common", "libwxmsw2.8-dev", "wx2.8-headers-msw" and if you need due to dependencies of "wx2.8-headers-msw" you have to install "wx2.8-headers-msw-force-depends".
(The debug-packages of wxWidgets are only needed if you want to debug wxWidgets itself.)

And of course you need "mingw32" and its dependencies "mingw32-binutils" and "mingw32-runtime".

That's the installation that works out of the box on all my debian systems with the setup described in my wiki-article (even on clean systems, where I never build wxWidgets or C::B from source).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 16, 2008, 12:45:52 pm
Code: [Select]
update-alternatives --list wx-configshows:

Code: [Select]
/usr/lib/wx/config/base-unicode-release-2.8
/usr/lib/wx/config/gtk2-unicode-release-2.8
/usr/lib/wx/config/base-unicode-debug-2.8
/usr/lib/wx/config/gtk2-unicode-debug-2.8

I did a "make uninstall" and "remove completely" the wxWidgets libraries yesterday, but I will try another time.
....

I obtain the same.

Of course, I have installed "mingw32" and its dependencies, if don't I won't be able to cross-compile for windows, and I can.

I tried exactly your wiki-article after reinstalling (before building wxWidgets), and it don't work for me, it can be because my system is not Debian, but Debian-based (Ubuntu).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 16, 2008, 01:16:33 pm
... it can be because my system is not Debian, but Debian-based (Ubuntu).

I just did a quick diff between hardys and feistys contents and the contents of the debian packages (all from apt.wxwidgets.org), but there seem to be no differences in directory-structure, the only differences are in examples and some python-wx packages.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 16, 2008, 02:31:29 pm
I give another try to your binaries. This time I set:

Compiler settings -> Other options
Code: [Select]
`wx-config --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --static` -U__WXGTK__  -U__WXGTK20__
Linker Settings -> Other options
Code: [Select]
`wx-config --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --static`
Search directories->Compiler and ->Linker:
Code: [Select]
/usr/i586-mingw32msvc/include/wx-2.8
I also have to modify /usr/include/wx-2.8/wx/platform.h line 196 from this:
Code: [Select]
#include "wx/setup.h"to this:
Code: [Select]
#ifdef __WXGTK__
#   include "wx/setup.h"
#endif

#ifdef __WIN32__
#   include "wx/msw/setup0.h"
#endif

If I don't do that I get this error: "wxClipboard requires wxDataObject". Both are enabled, but without including "msw/setup0.h" the "wxUSE_DATAOBJ" needed remains 0 when it has to be 1.

With this, when I build the Windows target I get a few warnings and this error:
Code: [Select]
ld | | cannot find -lwx_gtk2u_richtext-2.8
||=== Build finished: 1 errors, 9 warnings ===|

With the warnings, it compile and run under windows, but no with that error.

And... that option? come from Code::Blocks? and why?

This time I attach the sample project and "default.conf".

[attachment deleted by admin]
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 16, 2008, 03:10:40 pm
The first (and major error):
Quote
    * In the Build options of the project you have to move `wx-config --cflags` from the global Compiler settings -> Other options to the one for the standard build targets (Debug and Release).

    Do the same for Linker Settings -> Other options.

    * To make it clear the Other options-tabs of the Compiler settings and Linker settings belonging to the whole project have to be empty (or only include settings that are valid for the Linux and the MS Windows targets).

(quote  from:http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Fixing_build_options (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Fixing_build_options))

The second error:
you missed the "--cflags" for compiler-settings and the "--libs" for linker settings from your "wx-config"-line.

see screenshot in the wiki:
(http://wiki.codeblocks.org/images/7/7c/CompilerSettings.png)

If these errors are corrected I can build the project without errors.

I think, I will include the full line for wx-config in the wiki (not only the screenshots) to make it a little bit more clear.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 16, 2008, 05:13:34 pm
The first error:
My global Compiler settings -> Other options and Settings -> Other options are empty so I have nothing to "move" as you write in your wiki-article, so thats the reason that I have no `wx-config --cflags` on my project build options.

The second error:
For the cross-compiler target, I haven't noticed the images in the wiki (so little) and I use the text only, so that's my fault.

I've just set the right options "--cflags" and "--libs" but I obtain the same as before:
-If I don't modify "platform.h": error: wxClipboard requires wxDataObject.
-If I don't add -U__WXGTK__ to project's Compiler settings->Other options: /usr/include/wx-2.8/wx/defs.h | 2820 | error: conflicting declaration ‘typedef struct GtkWidget* WXWidget’.
-If I add it: ld | | cannot find -lwx_gtk2u_richtext-2.8.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 16, 2008, 06:09:12 pm
The first error:
My global Compiler settings -> Other options and Settings -> Other options are empty so I have nothing to "move" as you write in your wiki-article, so thats the reason that I have no `wx-config --cflags` on my project build options.

Here again: In the Build options of the project you have to move `wx-config --cflags` from the global Compiler settings -> Other options to the one for the standard build targets (Debug and Release).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 16, 2008, 07:05:28 pm
Sorry. It's the first time I read about global settings in the project.  :oops: Just now I only know settings of the targets.

Thank you for your effort. Now it works.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 16, 2008, 07:12:55 pm
Sorry. It's the first time I read about global settings in the project.  :oops: Just now I only know settings of the targets.

Thank you for your effort. Now it works.
Nice to hear.

I think the expression "Global settings of the project" can be misleading.
I will think about a better phrase for it.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Ganbito on August 24, 2008, 11:43:37 am
From jens' wiki-article:
Quote
Until now I haven't been able to make a cross-compiled program run on MS Windows if I did not use the static libraries.

I can!!!

I build my sample application with shared wxMSW (from your repository) and I test it on 64bit Windows Vista (I have no XP available today, perhaps tomorrow...). It start to ask for some (two for the sample) .dll's that can be found in /usr/i586-mingw32msvc/lib, I put them in the same directory of my .exe and it works.

As you build wxMSW with multiple .dll's, depending on the application, the application will require different .dll's, making it bad to distribute so I try building an monolithic library adding --enable-monolithic to my ./configure command. As it was a test I installed this monolithic version of the default location /usr/local/for not corrupting your wxMSW if it don't work. Then I build my sample project with this shared library and get the .dll from /usr/local/lib and it works right on my 64bit Vista with the advantage of one .dll needed for all the cases.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: era506 on September 24, 2008, 02:10:42 am
Hi!!
I'm trying to build and run a wxWidgets test project but I'm getting a lot o errors. I've followed the wiki howto (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux) step by step and also tried some things I read above in this thread but I still can't build and/or run my wxWidgets test app. Can someone help me?
Here is the build log:

Code: [Select]
-------------- Build: Release in Prueba2 ---------------

Compiling: Prueba2App.cpp
i586-mingw32msvc-g++: unrecognized option '-pthread'
In file included from /usr/include/wx-2.8/wx/platform.h:293,
                 from /usr/include/wx-2.8/wx/defs.h:21,
                 from /usr/include/wx-2.8/wx/event.h:15,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/chkconf.h:1817:9: error: #error "wxClipboard requires wxDataObject"
In file included from /usr/include/wx-2.8/wx/event.h:15,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/defs.h:2820: error: conflicting declaration ‘typedef struct GtkWidget* WXWidget’
/usr/include/wx-2.8/wx/defs.h:2611: error: ‘WXWidget’ has a previous declaration as ‘typedef void* WXWidget’
In file included from /usr/include/wx-2.8/wx/clntdata.h:17,
                 from /usr/include/wx-2.8/wx/event.h:18,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/hashmap.h: In member function ‘wxLongToLongHashMap_wxImplementation_HashTable::Node** wxLongToLongHashMap_wxImplementation_HashTable::GetNodePtr(const long int&) const’:
/usr/include/wx-2.8/wx/hashmap.h:714: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /usr/include/wx-2.8/wx/event.h:18,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/clntdata.h: In member function ‘wxShadowObjectMethods_wxImplementation_HashTable::Node** wxShadowObjectMethods_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:
/usr/include/wx-2.8/wx/clntdata.h:20: warning: dereferencing type-punned pointer will break strict-aliasing rules
/usr/include/wx-2.8/wx/clntdata.h: In member function ‘wxShadowObjectFields_wxImplementation_HashTable::Node** wxShadowObjectFields_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:
/usr/include/wx-2.8/wx/clntdata.h:25: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /usr/include/wx-2.8/wx/event.h:21,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/gdicmn.h: In member function ‘wxStringToColourHashMap_wxImplementation_HashTable::Node** wxStringToColourHashMap_wxImplementation_HashTable::GetNodePtr(const wxString&) const’:
/usr/include/wx-2.8/wx/gdicmn.h:544: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from /usr/include/wx-2.8/wx/utils.h:21,
                 from /usr/include/wx-2.8/wx/cursor.h:41,
                 from /usr/include/wx-2.8/wx/event.h:22,
                 from /usr/include/wx-2.8/wx/app.h:20,
                 from /home/era506/Desktop/Prueba2/Prueba2App.h:13,
                 from /home/era506/Desktop/Prueba2/Prueba2App.cpp:10:
/usr/include/wx-2.8/wx/filefn.h: At global scope:
/usr/include/wx-2.8/wx/filefn.h:398: error: zero width for bit-field ‘wxAssert_399::BadFileSizeType’
In file included from /home/era506/Desktop/Prueba2/Prueba2App.cpp:14:
/usr/include/wx-2.8/wx/image.h: In member function ‘wxImageHistogramBase_wxImplementation_HashTable::Node** wxImageHistogramBase_wxImplementation_HashTable::GetNodePtr(const long unsigned int&) const’:
/usr/include/wx-2.8/wx/image.h:136: warning: dereferencing type-punned pointer will break strict-aliasing rules
Process terminated with status 1 (0 minutes, 2 seconds)
4 errors, 5 warnings
 
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on September 24, 2008, 07:13:45 am
I've followed the wiki howto (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux) step by step and also tried some things I read above in this thread but I still can't build and/or run my wxWidgets test app.

You did not follow my howto step by step, because you are still using linux parameters for cross-compiling, that can't work.

Read this (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Fixing_build_options) carefully.

Please post the full commandline next time.
How to turn on full comandline logging:
Change "Settings -> Compiler and debugger... -> Global compiler settings -> Other settings(rightmost tab) -> Compiler logging" to "Full commandline".
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: era506 on September 24, 2008, 07:36:54 am
Wow! I'm an idiot!!! You were absolutely right!! I didn't read the part that says "belonging to the whole project have to be empty"!! :oops: After that I didn't get any errors but the proyect still didn't run, so I executed "wine Prueba.exe" from gnome-terminal and the following output showed:

Code: [Select]
[email protected]:~/Desktop/Prueba/bin$ wine Prueba.exe
err:module:import_dll Library mingwm10.dll (which is needed by L"Z:\\home\\era506\\Desktop\\Prueba\\bin\\Prueba.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\era506\\Desktop\\Prueba\\bin\\Prueba.exe" failed, status c0000135

Then, I remembered reading something about mingwm10.dll on your howto, so I ungzipped the .dll from /usr/share/doc/mingw32-runtime/ to the Prueba.exe's directory and voilà! It worked!! I apollogize for not reading carefully!!  :oops:
Thank you very much for your help!!!
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: pianoplayer326 on January 04, 2009, 02:59:50 am
hi, I'm having some trouble cross-compiling and am lost as to what step to take next in finding out how to make it work (not something that happens often).  The basic "hello, world" console app compiles fine but I have a project that I've been working on that won't compile for windows and I have some general questions regarding the process,

my project uses libraries glfw, ftgw, and box2d.  It doesn't seem the problem is in libraries though because the error messages have only to do with header files, like in this one example:

Code: [Select]
In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/i586-mingw32msvc/bits/c++locale.h:49,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/iosfwd:45,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/bits/stl_algobase.h:70,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/memory:53,
                 from /usr/include/freetype2/../Source/Dynamics/b2Body.h:26,
                 from /usr/include/Box2D.h:41,
                 from /home/dantarius/codeblocks/physics/main.cpp:6:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio: At global scope:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:171: error: ‘::vfscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:172: error: ‘::vscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:174: error: ‘::vsscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:182: error: ‘__gnu_cxx::vfscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:183: error: ‘__gnu_cxx::vscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:185: error: ‘__gnu_cxx::vsscanf’ has not been declared

the errors are coming from well-established files like cstdio, cwchar, and cstdlib, which leads me to believe that there are some odd #defines happening.  as far as I know, there aren't any platform-specific #defines happening aside from the windows-type ones from this tutorial, as these libraries are multi-platform.  do I have to compile a new, different set of libraries for these sub-systems, in order to successfully cross-compile a windows binary?  I'll throw in the entire build log for good measure.

Code: [Select]
Compiling: main.cpp
In file included from /usr/include/freetype2/../Source/Collision/Shapes/../../Common/b2Math.h:25,
                 from /usr/include/freetype2/../Source/Collision/Shapes/b2Shape.h:22,
                 from /usr/include/freetype2/../Source/Collision/Shapes/b2CircleShape.h:22,
                 from /usr/include/Box2D.h:36,
                 from /home/dantarius/codeblocks/physics/main.cpp:6:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:164: error: ‘::lldiv_t’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:170: error: ‘::_Exit’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:177: error: ‘::llabs’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:179: error: ‘lldiv_t’ does not name a type
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:183: error: ‘::lldiv’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:198: error: ‘::strtof’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:199: error: ‘::strtold’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:206: error: ‘__gnu_cxx::lldiv_t’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:208: error: ‘__gnu_cxx::_Exit’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:211: error: ‘__gnu_cxx::llabs’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:212: error: ‘__gnu_cxx::div’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:213: error: ‘__gnu_cxx::lldiv’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:216: error: ‘__gnu_cxx::strtof’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdlib:219: error: ‘__gnu_cxx::strtold’ has not been declared
In file included from /usr/include/Box2D.h:39,
                 from /home/dantarius/codeblocks/physics/main.cpp:6:
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h: In member function ‘virtual void b2ContactListener::Add(const b2ContactPoint*)’:
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h:95: warning: statement has no effect
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h: In member function ‘virtual void b2ContactListener::Persist(const b2ContactPoint*)’:
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h:99: warning: statement has no effect
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h: In member function ‘virtual void b2ContactListener::Remove(const b2ContactPoint*)’:
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h:103: warning: statement has no effect
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h: In member function ‘virtual void b2ContactListener::Result(const b2ContactResult*)’:
/usr/include/freetype2/../Source/Dynamics/b2WorldCallbacks.h:106: warning: statement has no effect
In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/i586-mingw32msvc/bits/c++locale.h:49,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/iosfwd:45,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/bits/stl_algobase.h:70,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/memory:53,
                 from /usr/include/freetype2/../Source/Dynamics/b2Body.h:26,
                 from /usr/include/Box2D.h:41,
                 from /home/dantarius/codeblocks/physics/main.cpp:6:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio: At global scope:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:171: error: ‘::vfscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:172: error: ‘::vscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:174: error: ‘::vsscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:182: error: ‘__gnu_cxx::vfscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:183: error: ‘__gnu_cxx::vscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cstdio:185: error: ‘__gnu_cxx::vsscanf’ has not been declared
In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/bits/postypes.h:46,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/iosfwd:49,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/bits/stl_algobase.h:70,
                 from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/memory:53,
                 from /usr/include/freetype2/../Source/Dynamics/b2Body.h:26,
                 from /usr/include/Box2D.h:41,
                 from /home/dantarius/codeblocks/physics/main.cpp:6:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:153: error: ‘::fwide’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:154: error: ‘::fwprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:155: error: ‘::fwscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:164: error: ‘::swprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:165: error: ‘::swscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:167: error: ‘::vfwprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:169: error: ‘::vfwscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:171: error: ‘::vswprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:173: error: ‘::vswscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:175: error: ‘::vwprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:177: error: ‘::vwscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:194: error: ‘::wcstof’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:205: error: ‘::wprintf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:206: error: ‘::wscanf’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:253: error: ‘::wcstold’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:262: error: ‘::wcstoll’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:263: error: ‘::wcstoull’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:270: error: ‘__gnu_cxx::wcstold’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:271: error: ‘__gnu_cxx::wcstoll’ has not been declared
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/include/c++/cwchar:272: error: ‘__gnu_cxx::wcstoull’ has not been declared
In file included from /home/dantarius/codeblocks/physics/main.cpp:12:
/home/dantarius/codeblocks/physics/camera.h: In function ‘void cameradragcb(int, int)’:
/home/dantarius/codeblocks/physics/camera.h:85: warning: unused variable ‘t’
In file included from /home/dantarius/codeblocks/physics/main.cpp:17:
/home/dantarius/codeblocks/physics/mainloop.h: In function ‘void mainloop()’:
/home/dantarius/codeblocks/physics/mainloop.h:52: warning: unused variable ‘t’
Process terminated with status 1 (0 minutes, 0 seconds)
40 errors, 6 warnings

command line:

Code: [Select]
i586-mingw32msvc-g++  -Wall  -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/include -I/usr/include/freetype2 -I/usr/include -I/usr/include/freetype2 -I/usr/i586-mingw32msvc/include  -c /home/dantarius/codeblocks/physics/main.cpp -o .objs/main.o
thanks for any help in advance,
brad

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Biplab on January 04, 2009, 03:25:43 am
Code: [Select]
i586-mingw32msvc-g++  -Wall  -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/include -I/usr/include/freetype2 -I/usr/include -I/usr/include/freetype2 -I/usr/i586-mingw32msvc/include  -c /home/dantarius/codeblocks/physics/main.cpp -o .objs/main.o

Remove -I/usr/include -I/usr/include/freetype2 -I/usr/include -I/usr/include/freetype2 from Compiler options. I'm quite sure that they contain header meant to be used in Linux.  :)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: pianoplayer326 on January 04, 2009, 05:18:05 am
I removed the original include directories and manually copied the sub-system headers I needed into the mingw-include area.  the header errors are gone!  for now.. but now I'm getting some other errors (undefined references) so I'll fiddle around with my libraries for a while.  I hope I don't have to compile an entirely different set for windows!  If that's what it takes, though, it'd still be worth it... tomorrow, lol.  if anyone still has ideas though I'm all ears.  Thanks for the tip Biplab!
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on January 04, 2009, 11:16:31 am
I removed the original include directories and manually copied the sub-system headers I needed into the mingw-include area.  the header errors are gone!  for now.. but now I'm getting some other errors (undefined references) so I'll fiddle around with my libraries for a while.  I hope I don't have to compile an entirely different set for windows!  If that's what it takes, though, it'd still be worth it... tomorrow, lol.  if anyone still has ideas though I'm all ears.  Thanks for the tip Biplab!

You can not use the same library for linux and windows builds.
the linux libs are under "/usr/lib[32|64]/" or "/usr/local/lib[32|64]", the windows libs under "/usr/i586-mingw32msvc/lib".

That a library is a cross-platform only means that the sources can be compiled on different platforms, the binaries are different.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: keke on January 05, 2009, 10:57:27 pm
Thanks for the tutorial. Have to say it's one of the most useful ones on the internet (even more useful than the stupid mingw faq).
But what you left out is what you doing before step2? What's the binary of the gui configurator you using? You said you use ubuntu, I didn't find it.
Anyway I don't need it because I wrote my makefile manually.
It's the first time when I even try to use mingw and I use it for crosscompiling a C app for windows on linux. After couple of hours trying it compiled all the c codes to obj and linked them but the final binary is a junk and broken.
I'm sure there is some prob with the flags I using. Please POST YOUR MAKEFILES, ALL OF YOU!
I need other good examples.

<pre>
OBJECTS = $(C_SRC:%.c=%.o)


# How to make a C file

%.o: %.c
        $(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o [email protected] -c $<

##
## TARGET DEFINITIONS
##

.PHONY: all clean

all: $(TARGET)

install:


##
## BUILD
##

$(TARGET): $(OBJECTS)
        $(CC) $(OBJECTS) $(LIB_PATHS) $(LIBS) -o $(TARGET)
</pre>

Also since I never heard of this gui configurator thingy you using I just copied the libs like kernel32.lib out from my SDK install in windows to my appdir (maybe I shouldnt?)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: defcronyke on August 03, 2009, 06:19:16 am
Step 14:

When I reached this step, compiled and tried to run my application I realized that for some reason codeblocks was trying to execute my .exe through /usr/bin/wine-auto (which I do not have)... So I created a simlink to wine:
Code: [Select]
# sudo ln -s /usr/bin/wine /usr/bin/wine-auto

Hi, I have code::blocks set up on debian to compile for win32 using MinGW just fine after following the tutorial in this thread, I have the debugger running just fine, however, I would really like to know where I can change the IDE settings to automatically run the resulting .exe file with wine when I select "Build and Run" (F9). I already had the /usr/bin/wine-auto file, but just to be sure, i removed it and symlinked /usr/bin/wine to /usr/bin/wine-auto, and it is not running the .exe with either of them. This is my build log:

Checking for existence: /home/bakeonandham/src/wxhelloworld2/bin/WinRelease/wxhelloworld2.exe
Executing: /home/bakeonandham/src/wxhelloworld2/bin/WinRelease/wxhelloworld2.exe  (in /home/bakeonandham/src/wxhelloworld2/.)
Process terminated with status 1 (0 minutes, 5 seconds)

I have looked through all the settings menus and I can't figure out what to change to make the .exe execute with wine. I have searched google and the code::blocks wiki, as well as these forums, and cannot find an answer, as apparently, it is just supposed to work. I started with a fresh install of the IDE and followed this tutorial exactly, and everything else works fine.

**EDIT**
Sorry for wasting everyone's time, I found the solution to my question right after I posted this. In case anyone else is wondering, here's how I made my .exe open with wine when I press (F9):

1. Open project
2. Select Project menu -> Build options
3. Click WinRelease (or whatever the win32 build target is called)
4. Select Pre/post build steps tab
5. In Post-build steps enter: /usr/bin/wine ${TARGET_OUTPUT_FILE}
6. Check the "Always execute, even if target is up-to-date" box
7. Click Ok
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 03, 2009, 10:59:40 am
**EDIT**
Sorry for wasting everyone's time, I found the solution to my question right after I posted this. In case anyone else is wondering, here's how I made my .exe open with wine when I press (F9):

1. Open project
2. Select Project menu -> Build options
3. Click WinRelease (or whatever the win32 build target is called)
4. Select Pre/post build steps tab
5. In Post-build steps enter: /usr/bin/wine ${TARGET_OUTPUT_FILE}
6. Check the "Always execute, even if target is up-to-date" box
7. Click Ok

In this case it will always run (after every build) and not only if you press F9.
Your OS (linux) has to know what it shall do with windows-executables.
You may find this wiki-article of interest :http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Normal_run (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Normal_run)

Nevertheless this does not always work.
You can also use the tool menu to run the windows-exe:
I use the following settings:

With the keybinder-plugin, you can set a shortcut to the new menu-entry in the tools menus and you are done.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: defcronyke on August 03, 2009, 09:44:11 pm
Thanks for the tip. I figured out the way to create an "open with wine" tool also, but I wanted to have the same functionality/behavior for Win32 target as for a Linux target. Surprisingly, I already had the binfmt-support package installed and my code::blocks was not opening with wine or wine-auto. I'm using Debian Squeeze by the way. Maybe a bug? Or maybe I need to set up the binfmt-support package in some special way. It's not really important to me though, as the post-build action is sufficient for my needs.

Now if I could just figure out how to build win32 files from a Linux amd64 machine... I don't expect an answer for that here though. :P
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: wilbefast on October 06, 2009, 06:09:16 pm
Is the first page still up-to-date? 2006 seems a bit far back, and no "insight" to be found (the link doesn't work)  :?

Just thought I'd ask before breaking something.


William
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: defcronyke on October 09, 2009, 09:12:18 pm
I have the debugger running just fine...

I shouldn't have said this, as I hadn't really tested debugging. I am actually having a problem with the debugger (windows version of GNU gdb 5.2.1 in wine wrapper script).

The Debugger starts fine but doesn't allow me to step through the program. Sometimes the output says "No symbol table is loaded.  Use the "file" command." While other times, it says "The program is not being run". I have selected the "Produce debugging symbols [-g]" option in my build target options...

Any ideas on how to debug a win32 target?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on October 09, 2009, 10:09:02 pm
Any ideas on how to debug a win32 target?

Read my comments about cross-debugging:
http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Debugging
 (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Debugging)

By the way:
gdb 5.2.1 does not even work correctly if you do not use it as cross-platform debugger, because it's a little bit outdated.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: defcronyke on October 10, 2009, 10:43:11 pm
Thanks for the tip. I tried gdb v7.0 and it works great!
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Green::horn on November 10, 2009, 12:25:13 am
Is the first page still up-to-date? 2006 seems a bit far back, and no "insight" to be found (the link doesn't work)  :?

Just thought I'd ask before breaking something.


William
Hi,

you can find and download the "insight.exe" from here:
http://sourceforge.net/projects/mingw/files/User%20Contributed/insight/ (http://sourceforge.net/projects/mingw/files/User%20Contributed/insight/)


Greenhorn
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: kencamargo on January 31, 2010, 11:22:54 pm
Thanks for the tip. I tried gdb v7.0 and it works great!

No matter what version of the debugger I try, I get errors and no debugging (either it aborts or I get a segfault). I am using a 64 bit version of Ubuntu, might this be getting in the way?

Thans in advance,
Ken
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: milope on February 04, 2010, 10:21:30 am
You can not use the same library for linux and windows builds.
the linux libs are under "/usr/lib[32|64]/" or "/usr/local/lib[32|64]", the windows libs under "/usr/i586-mingw32msvc/lib".

That a library is a cross-platform only means that the sources can be compiled on different platforms, the binaries are different.
Helo guys,

Same problem : I need to use libxml2 in  a cross project .
 - I tried lots of manips like to put libxml2 win32 on mingw directory  (it give /usr/i586-mingw32msvc/lib/libxml2_a.lib  and /usr/i586-mingw32msvc/include/libxml/lots-of-.h-files ) but nothing work...

Any body can help me ?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on February 04, 2010, 12:25:36 pm
Any body can help me ?
What about adding it to the libraries to link against and providing the path to the lib to the linker directories in the project (target) settings?

However, without a full compiler log of the actual error you won't get much help.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: rcoll on February 04, 2010, 02:13:51 pm
You can not use the same library for linux and windows builds.
the linux libs are under "/usr/lib[32|64]/" or "/usr/local/lib[32|64]", the windows libs under "/usr/i586-mingw32msvc/lib".

That a library is a cross-platform only means that the sources can be compiled on different platforms, the binaries are different.
Helo guys,

Same problem : I need to use libxml2 in  a cross project .
 - I tried lots of manips like to put libxml2 win32 on mingw directory  (it give /usr/i586-mingw32msvc/lib/libxml2_a.lib  and /usr/i586-mingw32msvc/include/libxml/lots-of-.h-files ) but nothing work...

Any body can help me ?

You are not clear -- are you trying to use the same binary library on both systems (linux and windows)?
If so, that will not work.

Ringo
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: milope on February 04, 2010, 02:44:05 pm
->MortenMacFly
Sorry, this is build log :
Code: [Select]
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|66|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|89|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|53|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|34|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|34|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|34|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|34|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|30|first defined here|
obj/Release/main.o:/home/equipement/dev/test_libxml2/main.cpp|30|first defined here|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
||Warning: .drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.data+0xec)||undefined reference to `_gzopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlWrapGzOpenUtf8]+0xf)||undefined reference to `_gzopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlWrapGzOpenUtf8]+0x6b)||undefined reference to `_gzdopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlInitPlatformSpecificIo]+0x75)||undefined reference to `_gzopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlGzfileOpen_real]+0x25)||undefined reference to `_gzdopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlGzfileOpenW]+0x42)||undefined reference to `_gzdopen'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlGzfileRead]+0x11)||undefined reference to `_gzread'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlGzfileWrite]+0x11)||undefined reference to `_gzwrite'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlGzfileClose]+0x7)||undefined reference to `_gzclose'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlFreeZMemBuff]+0x13)||undefined reference to `_deflateEnd'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlCreateZMemBuff]+0xa8)||undefined reference to `_deflateInit2_'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlCreateZMemBuff]+0x102)||undefined reference to `_crc32'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlZMemBuffAppend]+0x52)||undefined reference to `_deflate'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlZMemBuffAppend]+0x6b)||undefined reference to `_crc32'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlZMemBuffGetContent]+0x34)||undefined reference to `_deflate'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[___xmlParserInputBufferCreateFilename]+0xbd)||undefined reference to `_gzread'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[___xmlParserInputBufferCreateFilename]+0xe1)||undefined reference to `_gzrewind'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xmlIO.obj):../xmlIO.c:(.text[_xmlFreeHTTPWriteCtxt]+0x2d)||undefined reference to `_deflateEnd'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlIconvWrapper]+0x59)||undefined reference to `_libiconv'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlCharEncCloseFunc]+0x3f)||undefined reference to `_libiconv_close'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlCharEncCloseFunc]+0x5d)||undefined reference to `_libiconv_close'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlByteConsumed]+0x6)||undefined reference to `__chkstk'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0xd2)||undefined reference to `_libiconv_open'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0xdf)||undefined reference to `_libiconv_open'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0xf8)||undefined reference to `_libiconv_open'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0x111)||undefined reference to `_libiconv_open'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0x137)||undefined reference to `_libiconv_close'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/encoding.obj):../encoding.c:(.text[_xmlFindCharEncodingHandler]+0x13d)||undefined reference to `_libiconv_close'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/valid.obj):../valid.c:(.text[_xmlValidBuildContentModel]+0x6)||undefined reference to `__chkstk'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/valid.obj):../valid.c:(.text[_xmlValidateElementContent]+0x6)||undefined reference to `__chkstk'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xpath.obj):../xpath.c:(.text[_xmlXPathFormatNumber]+0xa4)||undefined reference to `__ftol2'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xpath.obj):../xpath.c:(.text[_xmlXPathFormatNumber]+0x1a4)||undefined reference to `__ftol2'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xpath.obj):../xpath.c:(.text[_xmlXPathIsPositionalPredicate]+0x3c)||undefined reference to `__ftol2'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xpath.obj):../xpath.c:(.text[_xmlXPathFloorFunction]+0x6a)||undefined reference to `__ftol2'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/xpath.obj):../xpath.c:(.text[_xmlXPathCeilingFunction]+0x6e)||undefined reference to `__ftol2'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanohttp.obj):../nanohttp.c:(.text[_xmlNanoHTTPFreeCtxt]+0xcb)||undefined reference to `_inflateEnd'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanohttp.obj):../nanohttp.c:(.text[_xmlNanoHTTPReadLine]+0x6)||undefined reference to `__chkstk'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanohttp.obj):../nanohttp.c:(.text[_xmlNanoHTTPScanAnswer]+0x449)||undefined reference to `_inflateInit2_'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanohttp.obj):../nanohttp.c:(.text[_xmlNanoHTTPRead]+0x97)||undefined reference to `_inflate'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanoftp.obj):../nanoftp.c:(.text[_xmlNanoFTPList]+0x6)||undefined reference to `__chkstk'|
/usr/i586-mingw32msvc/lib/libxml2.a(int.a.msvc/nanoftp.obj):../nanoftp.c:(.text[_xmlNanoFTPGet]+0x6)||undefined reference to `__chkstk'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 36 warnings ===|

-> rcoll
My program work fine under linux, with gcc and distrib libxml2-2.7.5 package -> Ok
I also want to build a windows version, also under linux, using mingw and libxml2-2.7.6.win32 binaries (/usr/i586-mingw32msvc/lib/libxml2_a.lib  and /usr/i586-mingw32msvc/include/libxml/lots-of-.h-files ) -> there is the problem...

I'v also tried to compile libxml with mingw but not successfully...

-----Edit...
Execution is ok if I put libxml2.dll into the program folder without any libs or .h with libxml2_a.lib (witch is renamed libxml2.a) and includes files in /usr/i586-mingw32msvc/.
But I want only one static file ! Can you tell me how can I do this ?

Thanks !
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on February 04, 2010, 08:21:44 pm
But I want only one static file ! Can you tell me how can I do this ?
You'll most likely need to create the static lib from the sources, sorry.

BTW: you have a broken project setup. It seems you imported a Visual Studio project and didn't clear up the settings for MinGW. Or you are using a wrong version of the VC compiler. I could tell but unfortunately you did not post the full "build log" (see my sig how to enable this). I don't need to see the errors, but the full log (including the compiler / linker commands). Just right-click on the "Build log" tab, select "Copy contents to clipboard" and paste here. Again: Don't forget to enable the full compiler log first.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: milope on February 05, 2010, 10:48:52 am
->MortenMacFly
The build log was older than my edit : there are no problems about it, now.

You'll most likely need to create the static lib from the sources, sorry.
I cant compile it statically into my program ?! Strange...

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on February 05, 2010, 11:18:51 am
I cant compile it statically into my program ?! Strange...
You can, but most libraries need a different set of parameters if compiled statically versus dynamically. Take wxWidgets: For a DLL you need to define WXUSINGDLL and alike. I don't know your library, but most likely there is a difference between the pure static and the DLL version. For the DLL you'll need to declare exported function differently for example. It may work, but I personally would do it "right".
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: milope on February 05, 2010, 12:10:46 pm
I cant compile it statically into my program ?! Strange...
You can, but most libraries need a different set of parameters if compiled statically versus dynamically. Take wxWidgets: For a DLL you need to define WXUSINGDLL and alike. I don't know your library, but most likely there is a difference between the pure static and the DLL version. For the DLL you'll need to declare exported function differently for example. It may work, but I personally would do it "right".
I agree, but I need to try it...
Can you explain me how can I compile my program to having this librarie (libxml2) inside my program ?



Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on February 05, 2010, 12:14:02 pm
Can you explain me how can I compile my program to having this librarie (libxml2) inside my program ?
No, I don't use this library. I would need to consult the documentation which you can do, too. ;-)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: milope on February 05, 2010, 02:06:45 pm
Can you explain me how can I compile my program to having this librarie (libxml2) inside my program ?
No, I don't use this library. I would need to consult the documentation which you can do, too. ;-)
I alredy done this, but without success, that's why I come here :)
I hope mingw can compile staticly (monoliticly) something if I give it the path of sources & headers of a lib...
The question is to know how can I said that to C::B. :s
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: usenet.tech.talk on March 28, 2010, 12:28:43 am
Hi All,

This post seemed like it would answer my quest for (relatively) cross compiler testing. Under Ubuntu, I followed all the steps except those related to insight (the html link to the binary is broken) and here's what I get:


-------------- Build: Debug in testing_mingw ---------------

Compiling: cpp-projects/testing_mingw/main.cpp
Assembler messages:
Fatal error: can't create obj/Debug/cpp-projects/testing_mingw/main.o: No such file or directory
Process terminated with status 1 (0 minutes, 3 seconds)
0 errors, 0 warnings
 
Is insight necessary to compile? I thought it was a debugger.

My second question is this : I'm actually on a Mac machine and use Ubuntu via a virtual machine. It would be simpler to try the above on Mac directly. Has anyone tried it?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on March 28, 2010, 10:51:15 am
First turn on full commandline logging : change "Settings -> Compiler and debugger... -> Global compiler settings -> [the compiler you use] -> Other settings(rightmost tab)" "Compiler logging" to "Full commandline" to see what is sent to the compiler.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: usenet.tech.talk on March 30, 2010, 02:41:56 am
Thanks.

First, by trying to compile I get
   Can't create object output directory obj/Debug/cpp-projects/testing_mingw.
Then, after clicking on OK,
   Can't create output directory bin/Debug/
Then, after clicking on OK,


-------------- Build: Debug in testing_mingw ---------------

i586-mingw32msvc-g++ -Wall -fexceptions  -g  -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/i586-mingw32msvc/include  -c cpp-projects/testing_mingw/main.cpp -o obj/Debug/cpp-projects/testing_mingw/main.o
Assembler messages:
Fatal error: can't create obj/Debug/cpp-projects/testing_mingw/main.o: No such file or directory
Process terminated with status 1 (2 minutes, 5 seconds)
0 errors, 0 warnings
 

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on March 30, 2010, 11:09:25 am
Did you check the access-rights for the directories, where the new directories should be created ?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: usenet.tech.talk on March 30, 2010, 03:52:35 pm
>Did you check the access-rights for the directories, where the new directories should be created ?

Thanks for following up on this.

Are you talking about the project directories or the installation directory? The project directories are somewhere in ~ where other projects were created with the default compiler w/o problem. As for installation, it's in an auto-detected path : Auto-detected installation path of "MingW32 Compiler" in "/usr".

By the way, I use Win7 (see signature for detail). Is this consequential for the defines below (Win95)?

The whole set up is summarized here:

#defines
WINVER=0x0400
__WIN95__
__GNUWIN32__
STRICT
HAVE_W32API_H
__WXMSW__
__WINDOWS__

Other linker options
-lstdc++
-lgcc
-lodbc32
-lwsock32
-lwinspool
-lwinmm
-lshell32
-lcomctl32
-lctl3d32
-lodbc32
-ladvapi32
-lodbc32
-lwsock32
-lopengl32
-lglu32
-lole32
-loleaut32
-luuid

Search directories
Compiler: /usr/i586-mingw32msvc/include
Linker: /usr/i586-mingw32msvc/lib
Resource compiler: /usr/i586-mingw32msvc/include

Compiler's installation directory: /usr
C Compiler : i586-mingw32msvc-gcc
C++ Compiler: i586-mingw32msvc-g++
Linker for dyn libs: i586-mingw32msvc-g++
Linker for static libs: i586-mingw32msvc-ar
Debugger: i586-mingw32msvc-gdb
Resource compiler: NA
Make program : make
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: usenet.tech.talk on April 02, 2010, 04:55:08 pm
Hi Jen, All,

I'm still stuck on this one. Could I ask for a little nudge from someone? Thank.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: drumspirit on April 01, 2011, 08:45:15 am
Omg !
Thank you guy for this awesome post !
I have checked out everywhere on the web for solution to compile from Linux to Win.
I haven't tried my executable on a windows platform yet but I guess your tuto is reliable. For sure it compiles in the good way and it creates .exe/windows executable.
Just hope programs don't crash once on a Win32 platform.

Anyway, thanks again, very helpfull !
Drumspirit who just suscribed to thank you guy :)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: radzi on April 06, 2011, 06:53:21 am
Hi, I've just started to use wxWidgets on Ubuntu. Tried sample code to compile on Ubuntu - ok. But not I'm trying to get it cross-compiled to Windows. Stuck at linker problem

Linking executable: bin/WinRelease/Testing001.exe
/usr/bin/ld: unrecognized option '--subsystem'
/usr/bin/ld: use the --help option for usage information

Any pointers on what's wrong with this?

Thanks.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on April 06, 2011, 08:14:55 am
Hi, I've just started to use wxWidgets on Ubuntu. Tried sample code to compile on Ubuntu - ok. But not I'm trying to get it cross-compiled to Windows. Stuck at linker problem

Linking executable: bin/WinRelease/Testing001.exe
/usr/bin/ld: unrecognized option '--subsystem'
/usr/bin/ld: use the --help option for usage information

Any pointers on what's wrong with this?

Thanks.


Did you read my wiki-article about a possible way to set up C::B to cross-compile wxWidgets applications for windows on linux ?
http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: tsolorio on November 25, 2011, 12:42:00 am
Step 4:

Click the Directories tab and the Compiler tab.
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

Click the Directories tab and the Linker tab:
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/lib

Click the Directories tab and the Resource Compiler tab:
Code: [Select]
Modify the path to read the following (where ix86 is your architecture type):
 /usr/i586-mingw32msvc/include

I've been looking through this thread and searching in this forum and in other wikis and forums but I get to Step 3 only. In step 4 the options are grayed out. It won't let me add anything under those tabs. I know this is an old thread but I would appreciate if someone has any idea about this. I'm running Linux Mint 12 and Code Blocks 10.05.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: RagnarDa on March 23, 2012, 05:07:19 pm
Hi guys!

I have tried to follow the guide http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux (http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux) doing it multiple times over. I don't think I've missed anything. I created a new wxWidget project in C::B and have done nothing to it, except whats in the guide. When I compile the Debug/Release targets (for Linux) it compiles and runs fine, but my "WinRelease" - target generates the following build error:

Code: [Select]
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h|13|fel: wx/app.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|14|fel: wx/menu.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|15|fel: wx/statusbr.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|16|fel: wx/frame.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|14|fel: wx/image.h: Filen eller katalogen finns inte|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h|16|error: expected class-name before ‘{’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|error: expected class-name before ‘{’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|23|error: expected `)' before ‘*’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|29|error: ‘wxCommandEvent’ has not been declared|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|30|error: ‘wxCommandEvent’ has not been declared|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|40|error: ISO C++ forbids declaration of ‘wxStatusBar’ with no type|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|40|error: expected ‘;’ before ‘*’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|43|error: ISO C++ forbids declaration of ‘DECLARE_EVENT_TABLE’ with no type|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|44|error: expected ‘;’ before ‘}’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|44|error: expected `;' before ‘}’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|17|error: expected constructor, destructor, or type conversion before ‘;’ token|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp||In member function ‘virtual bool wxLinuxApp::OnInit()’:|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|23|error: ‘wxInitAllImageHandlers’ was not declared in this scope|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|26|error: no matching function for call to ‘wxLinuxFrame::wxLinuxFrame(int)’|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|note: candidates are: wxLinuxFrame::wxLinuxFrame()|
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h|20|note:                 wxLinuxFrame::wxLinuxFrame(const wxLinuxFrame&)|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|27|error: ‘class wxLinuxFrame’ has no member named ‘Show’|
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp|28|error: ‘SetTopWindow’ was not declared in this scope|
||=== Build finished: 20 errors, 0 warnings ===|

"Filen eller katalogen finns inte" means "File or folder doesnt exist".

Im using Ubuntu 11.10, C::B 10.05, wxMSW-2.8.12 (wxWidget) and mingw32 is latest (from apt-get).

I've searched the forum the best I could but I'm new to this, and Linux in general...

EDIT:
When i execute wx-config --list i get:

Code: [Select]
  Default config is gtk2-unicode-release-2.8

  Default config will be used for output

  Alternate matches:
    base-unicode-release-2.8

But when i execute /usr/i586-mingw32msvc/lib/wx/config/i586-mingw32msvc-msw-unicode-release-static-2.8 --list i get

Code: [Select]
  Default config is i586-mingw32msvc-msw-unicode-release-static-2.8

  Default config will be used for output

  Also available in /usr/i586-mingw32msvc:
    i586-mingw32msvc-msw-unicode-static-2.9
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on March 23, 2012, 05:51:50 pm
target generates the following build error:
Always the full build log, please...
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: RagnarDa on March 23, 2012, 09:50:46 pm
Always the full build log, please...

Rgr.

Code: [Select]
-------------- Build: WinRelease in wxLinux ---------------

Linking executable: bin/Release/wxLinux.exe
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: oBFusCATed on March 23, 2012, 10:13:58 pm
This is not the full log.
See here for details: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: RagnarDa on March 23, 2012, 10:55:18 pm
This is not the full log.
See here for details: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

OK.

Code: [Select]
-------------- Build: WinRelease in wxLinux ---------------

i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib/ -L/usr/i586-mingw32msvc/lib  -o bin/Release/wxLinux.exe obj/Release/wxLinuxApp.o obj/Release/wxLinuxMain.o   -s  -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid 
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on March 23, 2012, 11:20:42 pm
obj/Release/wxLinuxApp.o: file not recognized: File format not recognized
...I don't know why, but that's the cause. Help yourself and find out what you are doing there...

In addition, you only show the linking process. What we are asking for is the full build process, so do a clean before or a complete new re-build.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: RagnarDa on March 23, 2012, 11:44:10 pm
I uninstalled mingw32 and sudo apt-get install'ed it again, did a clean and a rebuild the project and this is what i got:

Code: [Select]
-------------- Clean: WinRelease in wxLinux ---------------

Cleaned "wxLinux - WinRelease"

-------------- Build: WinRelease in wxLinux ---------------

i586-mingw32msvc-g++ -Wall  -O2      -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include  -c /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp -o obj/Release/wxLinuxApp.o
I fil inkluderad från /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:10:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h:13:20: fel: wx/app.h: Filen eller katalogen finns inte
I fil inkluderad från /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:13:
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:14:21: fel: wx/menu.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:15:25: fel: wx/statusbr.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:16:22: fel: wx/frame.h: Filen eller katalogen finns inte
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:14:22: fel: wx/image.h: Filen eller katalogen finns inte
In file included from /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:10:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.h:16: error: expected class-name before ‘{’ token
In file included from /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:13:
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: error: expected class-name before ‘{’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:23: error: expected `)' before ‘*’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:29: error: ‘wxCommandEvent’ has not been declared
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:30: error: ‘wxCommandEvent’ has not been declared
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:40: error: ISO C++ forbids declaration of ‘wxStatusBar’ with no type
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:40: error: expected ‘;’ before ‘*’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:43: error: ISO C++ forbids declaration of ‘DECLARE_EVENT_TABLE’ with no type
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:44: error: expected ‘;’ before ‘}’ token
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:44: error: expected `;' before ‘}’ token
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:17: error: expected constructor, destructor, or type conversion before ‘;’ token
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp: In member function ‘virtual bool wxLinuxApp::OnInit()’:
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:23: error: ‘wxInitAllImageHandlers’ was not declared in this scope
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:26: error: no matching function for call to ‘wxLinuxFrame::wxLinuxFrame(int)’
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: note: candidates are: wxLinuxFrame::wxLinuxFrame()
/home/christoffer/Projekt/wxLinux/wxLinuxMain.h:20: note:                 wxLinuxFrame::wxLinuxFrame(const wxLinuxFrame&)
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:27: error: ‘class wxLinuxFrame’ has no member named ‘Show’
/home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp:28: error: ‘SetTopWindow’ was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
20 errors, 0 warnings

Thank you for your quick response!
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on March 23, 2012, 11:53:41 pm
I uninstalled mingw32 and sudo apt-get install'ed it again, did a clean and a rebuild the project and this is what i got:
Code: [Select]
i586-mingw32msvc-g++ -Wall  -O2      -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include  -c /home/christoffer/Projekt/wxLinux/wxLinuxApp.cpp -o obj/Release/wxLinuxApp.o
See, and finally we got all information we need. ::)

As you see from the compiler step, you are missing to provide the full set of required wxWidgets flags to compile your wxWidgets app, like include folders, and #defines. So the compiler doesn't not know where to search for the include files as shown in the error messages. Adjust your project settings accordingly and it will work. Inspect the instruction of the wxWidgets library to now how to do so. This is no longer a Code::Blocks issue -> please don't post in this thread again therefore.

Next time, to speed up things, read the forum rules (you agreed to when registering with the forum btw) and post the right stuff in the first place. Also note this (again):
http://forums.codeblocks.org/index.php/topic,9996.0.html
Thank you.

Edit: Typos.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Leshyk on November 20, 2012, 11:12:10 pm
Thank you very much for this review! It works fine but debuging...

More precisely:
My system is ubuntu. The goal is to compile dll as a plugin for some windows application.
Following the instructions I was able to compile, link and to begin debugging. For debugging mingw32-gdb.exe under wine was used.

The C::B was able to put breakpoint but when the programm stops I have the following error in the debugger window: "The program has stopped on a breakpoint but the breakpoint format is not recognized".

In the source code (http://fossies.org/dox/codeblocks-10.05-src/gdb__driver_8cpp_source.html) I found that this error message appears when the result output doesn't coincide with regexp either reBreak or reBreak_or32 (*). Manually I would say that this string should coincide with reBreak_or32 and, so, there is two cases why the error appears 1) somehow reBreak instead of reBreak_or32 is applied (I tried to change development flower in the C::B settings to 'or32' but nothing changed) 2) there are some invisible symbols which don't coincide with regexp

1) The further way of searching for the solution is to rebuild debuggergdb but how can I rebuild only that module and where should I put the rebuilt module?
2) What else can I do to make the debugger working?

(*) To the developers of debuggergdb, Just a curiosity:
Why you use this kind of code
Code: [Select]
  43 #ifdef __WXMSW__
   44     static wxRegEx reBreak(_T("([A-Za-z]*[:]*)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
   45     static wxRegEx reBreak_or32(_T("\032\032([A-Za-z]:)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-z]+)"));
   46 #else
   47     static wxRegEx reBreak(_T("\032\032([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
   48     static wxRegEx reBreak_or32(_T("")); // not used on linux, but make sure it exists otherwise compilation fails on linux (if (platform::windows) blabla)
   49 #endif
and then trying to select the right version of reBreak or reBreake_or32 while it is mush more understandable to use one regex like this
Code: [Select]
static wxRegEx reBreak(_T("\{\032\032\}?(\{[A-Za-z]*[:]*\}?)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
The performance here seems to be not so much important...
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: oBFusCATed on November 20, 2012, 11:21:15 pm
Because we're not regex masters and the wxregex is not that powerful (I suppose your regex would work, though).
Try it and tell us what is the result...

To rebuild, if I were you I'd use the autotools system with a prefix to modify and rebuild C::B.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Leshyk on November 20, 2012, 11:40:45 pm
Thank you,
Quote
autotools system with a prefix to modify
I am not familiar with autotools, and as far as I understand, prefix is used to give the install directory?
So I will still need to rebuild the whole C::B? Is it save to modify Makefile.am/SUBDIRS to limit the number of built projects?
By default where the new plugin should be placed or "make install" will do everything?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: oBFusCATed on November 21, 2012, 12:39:49 am
If you're on a current machine the rebuild will take around 10 minutes and you would have finished with it.

Code: [Select]
checkout lastest svn version
./bootstrap
./configure --prefix=full_path_to_install --with-contrib-plugins=all
make jN && make install
If you don't want to build contrib plugins you can skip the last part of the configure command, then it will be even faster.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Leshyk on November 21, 2012, 03:13:22 pm
Quote
If you don't want to build contrib plugins you can skip the last part of the configure command, then it will be even faster.
I have expected that I should rebuild all the C::B after a small modification. However it saves the result of previous builds, so 10 minutes is just for the first time and it is not a problem.

I have corrected the file, which I took from the svn/trunk. I have opportunity to test it only in linux -- native linux and crosscompiling. In both cases the code works fine. I add some comments of what I have changed.

Edit: typos
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: oBFusCATed on November 21, 2012, 03:21:26 pm
How about providing a patch?
See here for the details: http://wiki.codeblocks.org/index.php?title=Creating_a_patch_to_submit_to_BerliOS_%28Patch_Tracker%29
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: Leshyk on November 21, 2012, 03:56:57 pm
Quote
How about providing a patch?
Done. Patch 003373.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: MortenMacFly on November 21, 2012, 04:21:07 pm
Done. Patch 003373.
Nice catch... everything generalising platform differences is usually welcome.

@oBFusCATed: A quick inspection reveals it doens't look bad, indeed. Hence I don't recall what the reBreak_or32 regexp was for. If you test the patch, can you ensure we don't break this particular "thingy"? (It seems a Windows only thing).
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: oBFusCATed on November 21, 2012, 05:09:33 pm
I'm not sure too, what type of breakpoints this code is used to detect, so some testing should be done here.
I'll apply this on my work C::B and see if there are problems on linux, for windows somebody else should test it.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: eddyq on December 01, 2012, 09:21:57 pm
This is off topic but I can't find anyplace to make a "new post". Can someone please tell me how to do a "new post"?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: markpotts on December 28, 2013, 10:05:31 pm
Any advice on doing the reverse, i.e. cross-compiling for Linux under Windows?
Mark
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: 71532 on August 09, 2014, 12:35:47 am
The following is just a very simple program writen in C++ that connects to a MySQL. I compile it with no errors, with the following line
g++ -o main main.cpp  -L/usr/include/mysql -lmysqlclient  -I/usr/include/mysql
that produces an executable that runs perfectly well.
/************************************
the example
*************************************/
#include<iostream>
#include<winsock.h>
#include<mysql.h>
#include<stdio.h>
using namespace std;
#define SERVER    "anilab"
#define USER      "anibal"
#define PASSWORD  "anigug"
#define DATABASE  "virtualsa"

int main() {
MYSQL *connect;
connect=mysql_init(NULL);
if(!connect) { cout<<"MySQL Initialization failed"; return 1;
}
connect=mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
if(connect) {   cout<<"connection Succeeded\n";
}else{           cout<<"connection failed\n";      }

MYSQL_RES *res_set;
MYSQL_ROW row;
mysql_query( connect, "SELECT id,nombre,apellido FROM users;" );
unsigned int i =0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);
cout << endl;
cout <<"\t --------------------------------------------------------------------- \t"<< endl;
while (((row= mysql_fetch_row(res_set)) !=NULL )) {
//cout<<" %s\n",row !=NULL?row : "NULL";
cout <<"\t | \t" << row << "\t | \t"<<  row[i+1] << "\t | \t"<< row[i+2] << "\t | \t" << endl;
cout <<"\t --------------------------------------------------------------------- \t"<< endl;
}
mysql_close (connect);
return 0;
}
/*********** end of file ***********/

Question: does anybody know of a way to compile this, using -for example- C::B, that will produce an executable for Windows ?
I had tried the set-up proposed at the top of this thread.
I get the following messages:(taken from the Build log)

i586-mingw32msvc-g++ -I/usr/include/mysql  -DBIG_JOINS=1  -fno-strict-aliasing   -DUNIV_LINUX -DUNIV_LINUX -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/i586-mingw32msvc/include  -c /home/xxxx/cpp/test1/main.cpp -o /home/xxxx/cpp/test1/main.o

i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib  -o /home/xxxx/cpp/test1/main /home/xxxx/cpp/test1/main.o  -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid  "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient"
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: unrecognized option '-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
This compiler (i586-mingw32msvc-g++ does actually produce a working executable from a simple "hello world" C++ source, so it seems a good compiler). Fact is: don't know how to make it work with MySQL libraries and headers.

Thanks
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: stahta01 on August 09, 2014, 12:47:00 am
The following is just a very simple program writen in C++ that connects to a MySQL. I compile it with no errors, with the following line
g++ -o main main.cpp  -L/usr/include/mysql -lmysqlclient  -I/usr/include/mysql

Question: does anybody know of a way to compile this, using -for example- C::B, that will produce an executable for Windows ?
I had tried the set-up proposed at the top of this thread.
I get the following messages:(taken from the Build log)

i586-mingw32msvc-g++ -I/usr/include/mysql  -DBIG_JOINS=1  -fno-strict-aliasing   -DUNIV_LINUX -DUNIV_LINUX -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/i586-mingw32msvc/include  -c /home/xxxx/cpp/test1/main.cpp -o /home/xxxx/cpp/test1/main.o

i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib  -o /home/xxxx/cpp/test1/main /home/xxxx/cpp/test1/main.o  -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid  "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient"
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: unrecognized option '-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
This compiler (i586-mingw32msvc-g++ does actually produce a working executable from a simple "hello world" C++ source, so it seems a good compiler). Fact is: don't know how to make it work with MySQL libraries and headers.

Thanks


Where did you enter "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" in Code::Blocks?
Did you enter the double quotes or CB?

I suggest trying the "For your project :" section of this FAQ.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: 71532 on August 09, 2014, 01:24:16 am
Hi ! Thanks for the quick reply.
The string "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" (without quotes), was entered at the Linker Settings tab ->Link libraries in C::B (I am running a Linux version of C::B)
I got it issuing a mysql_config --cflags and mysql_config --libs to get the compilation and linking "recommended" switches for the MySQL server installed.
I had seen the link you suggested, I already set up the C::B as advised at the top of this post.
It seems that I need to continue searching to see if someone, somewhere, sometime, had ever cross-compiled a C++ source code to obtain a Windows binary executable format able to run on Windows and connect to a MySQL database running elsewhere. I did it, around 15 years ago, with some stuff I do not have anymore (not even a clue). Now I need to do it but I don't know how...
Thanks
Bye

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: stahta01 on August 09, 2014, 02:08:32 am
Hi ! Thanks for the quick reply.
The string "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" (without quotes), was entered at the Linker Settings tab ->Link libraries in C::B (I am running a Linux version of C::B)
I got it issuing a mysql_config --cflags and mysql_config --libs to get the compilation and linking "recommended" switches for the MySQL server installed.
I had seen the link you suggested, I already set up the C::B as advised at the top of this post.
It seems that I need to continue searching to see if someone, somewhere, sometime, had ever cross-compiled a C++ source code to obtain a Windows binary executable format able to run on Windows and connect to a MySQL database running elsewhere. I did it, around 15 years ago, with some stuff I do not have anymore (not even a clue). Now I need to do it but I don't know how...
Thanks
Bye

That is the wrong location for most of this "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient"
The "mysqlclient" should be in the Link libraries.
The rest should be in other places.
This "/usr/lib/mysql" in linker search folder/path.
This "-Wl,-Bsymbolic-functions" in linker extraother settings.
No idea where "-rdynamic" should be; but, a good guess is linker extraother settings.

Edit: Remember to use the correct tick marks around `mysql_config --cflags` and `mysql_config --libs`
My guess of where they belong.
Other linker settings: `mysql_config --libs`
Other compiler settings: `mysql_config --cflags`

Note: I have been told both that CB needs exited and restarted for things in "`" ticks to be reread and that CB does NOT need exited.

Tim S.

Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: 71532 on August 09, 2014, 02:55:06 am
OK Tim.
I already stated where did I get the compiler and linker options, they are in my reply to your reply.
The switches, or compiler and linker options, were obtained from the command line, hence, no need for back-ticks, though they can be called adding for example $(mysql_config --link) whenever the compiler is called from a single line, from a command line or from a shell script.
Now, I will follow your idea of "simpler" link options, although, if you take a look, I already put -lmysqlclient as a switch in the linker tab, as I showed in my last post. Perhaps, simpler options yield a solution.
Fact is, I can produce an executable for Windows (without calling mysql stuff) and an executable for Linux (with mysql stuff) but fail to produce a running Windows binary with mysql abilities...
I wonder if someone (besides me) had ever did it ... It seems hard to me to think that nobody had ever tried it before... Even the people at Code::Blocks...
Anyway, thanks for your attention.
Regards
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: stahta01 on August 09, 2014, 03:13:46 am
Please explain why the build log has double quotes around  the part that is causing the error.

Tim S.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: 71532 on August 09, 2014, 04:15:48 am
OK Tim. Thanks for your concern.
Why the double quotes ? It is pointed by the linker. So probably I should not use it as a linking option, though the MySQL command line
mysql_config --libs
yields that string. I also tried not to use it, and I got many more errors. I just installed Code::Blocks. Now, if, as it seems to me, nobody here had attempted a cross-compilation of a C++ source code to produce a Windows executable able to connect to MySQL, I do not have the time to investigate nor, perhaps, the knowledge of how this thing was written, what are the messages, why are those switches rejected. Maybe the explanation is available. Maybe, it is not. What does the error means ? Well, maybe this will help the C::B developers to explain more clear where to put the things, or why are they "rejected" when they are placed in the "assumed" right place. As I see the things, if C:B does not solve my problem -and it seems it does not- I need to carry on. As said, no time to investigate, not exactly around C::B, maybe I will turn to the compiler, which is a cross-compiler, that does not find the libraries it has to link. So my problem is no C:B-related, my problem is of some other kind, maybe, I need other switches, because I can compile an ELF Linux binary that runs perfectly well, and a Windows binary that runs perfectly well, but not a Windows binary that connects to MySQL. I see I have a problem at linking stage, but I don't know how to solve it. So I should look somewhere else.
Thanks for your concern.
Bye
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 09, 2014, 10:06:07 am
It looks like you try to link the mysql lib from the system (linux-lib) with a mingw-app (cross-compiled for windows).
How should this work ?
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: 71532 on August 09, 2014, 02:30:04 pm
Won't.
Thus, the only way out will be install a MySQL and a Code::Blocks on a Windows box, and compile there.
I already installed a MySQL.
Any other advice in this regard ?
Thank you !
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: jens on August 09, 2014, 03:38:37 pm
It might be possible to use mysql-libs (and headers) from windows on linux (for cross-compiling) or (better) do a cross-builld of mysql on linux.
But that's far away from the scope of our forum, sorry.
Title: Re: Howto - Cross Compiling in Linux using MingW32
Post by: raiz on May 08, 2016, 12:28:06 pm
thanks for information