Author Topic: Howto - Cross Compiling in Linux using MingW32  (Read 632427 times)

Offline milope

  • Single posting newcomer
  • *
  • Posts: 5
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #75 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...


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #76 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".
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline milope

  • Single posting newcomer
  • *
  • Posts: 5
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #77 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 ?




Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #78 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. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline milope

  • Single posting newcomer
  • *
  • Posts: 5
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #79 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

Offline usenet.tech.talk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #80 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?
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #81 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.

Offline usenet.tech.talk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #82 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
 

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

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #83 on: March 30, 2010, 11:09:25 am »
Did you check the access-rights for the directories, where the new directories should be created ?

Offline usenet.tech.talk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #84 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
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

Offline usenet.tech.talk

  • Single posting newcomer
  • *
  • Posts: 4
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #85 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.
MacBook5,1   Mac OS X (10.6.1), Unbuntu 9.10 (via Virtual Machine),  Code Blocks 8.02

drumspirit

  • Guest
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #86 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 :)

Offline radzi

  • Single posting newcomer
  • *
  • Posts: 2
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #87 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #88 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

tsolorio

  • Guest
Re: Howto - Cross Compiling in Linux using MingW32
« Reply #89 on: November 25, 2011, 12:42:00 am »
Step 4:

Click the Directories tab and the Compiler tab.
Code
 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
 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
 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.