News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Howto - Cross Compiling in Linux using MingW32

Started by visualphoenix, June 16, 2006, 01:52:25 AM

Previous topic - Next topic

milope

->MortenMacFly
The build log was older than my edit : there are no problems about it, now.

Quote from: MortenMacFly on February 04, 2010, 08:21:44 PM
You'll most likely need to create the static lib from the sources, sorry.
I cant compile it statically into my program ?! Strange...


MortenMacFly

Quote from: milope on February 05, 2010, 10:48:52 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".
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

milope

Quote from: MortenMacFly on February 05, 2010, 11:18:51 AM
Quote from: milope on February 05, 2010, 10:48:52 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".
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 ?




MortenMacFly

Quote from: milope on February 05, 2010, 12:10:46 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. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

milope

Quote from: MortenMacFly on February 05, 2010, 12:14:02 PM
Quote from: milope on February 05, 2010, 12:10:46 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

usenet.tech.talk

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?
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

Jenna

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.

usenet.tech.talk

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


MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

Jenna

Did you check the access-rights for the directories, where the new directories should be created ?

usenet.tech.talk

>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
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

usenet.tech.talk

Hi Jen, All,

I'm still stuck on this one. Could I ask for a little nudge from someone? Thank.
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

drumspirit

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 :)

radzi

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.

Jenna

Quote from: 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.


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

tsolorio

Quote from: visualphoenix on June 16, 2006, 01:52:25 AM
Step 4:

Click the Directories tab and the Compiler tab.

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:

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:

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.