LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-18-2012, 09:49 PM   #1
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Slackware
Posts: 89

Rep: Reputation: 22
Question Building a cross-compiler for windows on linux


Greetings,
I need to develop apps for linux and windows, but I prefer building them only my linux box, because 1) It's my main OS, 2) It's faster 3) I don't want to reboot every time I want to rebuild.
I've seen lots of (very old) tutorials on how to set up a cross compiler, but I can't manage to get the resulting cross-compiler to work.

Here's how far I've went:
Packages:
Code:
binutils-2.22
gcc-core-4.6.2
mingwrt-3.20 (from cvs)
w32api-3.17 (from cvs)
Variables:
Code:
$PREFIX=$HOME/w32
$TARGET=i686-pc-mingw32
--
binutils builds fine with
Code:
../configure --prefix=$PREFIX --target=$TARGET && make && make install
copy all the headers from mingw runtime and win32 api:
Code:
cp -Rv mingwrt/include $PREFIX; cp -Rv w32api/include $PREFIX
Next up is gcc:
Code:
../configure --prefix=$PREFIX --target=$TARGET --disable-nls --disable-threads --enable-languages=c && make all-gcc && make install-gcc
Everything works fine:
Code:
axtroz ~/source/win32/w32api/build $ cd $PREFIX
axtroz ~/w32 $ i686-pc-mingw32-ld -V
GNU ld (GNU Binutils) 2.22
  Supported emulations:
   i386pe
axtroz ~/w32 $ i686-pc-mingw32-gcc -dumpmachine
i686-pc-mingw32
axtroz ~/w32 $ i686-pc-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=i686-pc-mingw32-gcc
COLLECT_LTO_WRAPPER=/home/axtroz/w32/libexec/gcc/i686-pc-mingw32/4.6.2/lto-wrapper
Target: i686-pc-mingw32
Configured with: ../configure --prefix=/home/axtroz/w32 --target=i686-pc-mingw32 --disable-threads --disable-nls --enable-languages=c
Thread model: single
gcc version 4.6.2 (GCC) 
axtroz ~/w32 $
The problem is here:

Code:
axtroz ~/w32 $ cat >> hello.c << EOF
> #include <stdio.h>
> int main() {
> printf("Hello, World!\n");
> return 0;
> }
> EOF
axtroz ~/w32 $ i686-pc-mingw32-gc
i686-pc-mingw32-gcc        i686-pc-mingw32-gcc-4.6.2  i686-pc-mingw32-gcov       
axtroz ~/w32 $ i686-pc-mingw32-gcc hello.c -o hello -Wall
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find crt2.o: No such file or directory
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find crtbegin.o: No such file or directory
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmingw32
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lgcc_eh
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lgcc
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmoldname
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmingwex
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmsvcrt
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmingw32
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lgcc_eh
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lgcc
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmoldname
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmingwex
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lmsvcrt
/home/axtroz/w32/lib/gcc/i686-pc-mingw32/4.6.2/../../../../i686-pc-mingw32/bin/ld: cannot find crtend.o: No such file or directory
collect2: ld returned 1 exit status
axtroz ~/w32 $
I've looked everywhere for at least 1 of the required libraries, but none were found. I've encountered these errors while trying to build the mingwrt, but then even a simple helloworld couldn't build. Help!
 
Old 01-20-2012, 07:28 AM   #2
Thor_2.0
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,209
Blog Entries: 23

Rep: Reputation: 279Reputation: 279Reputation: 279
...of course, there is a far easier way, use Java. That IS cross platform...

But, I am a Java affectionado/progger...

Maybe an easier approach? Dunnow.

Thor
 
Old 01-20-2012, 11:44 AM   #3
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Slackware
Posts: 89

Original Poster
Rep: Reputation: 22
Thumbs up

Thank you for the suggestion, though I finally managed to build my cross compiler successfully.
I used as examples the arch PKGBUILD scripts from this post with a few modifications: https://bbs.archlinux.org/viewtopic....988450#p988450
 
1 members found this post helpful.
Old 01-20-2012, 12:28 PM   #4
Thor_2.0
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,209
Blog Entries: 23

Rep: Reputation: 279Reputation: 279Reputation: 279
Thanks for sharing!
 
Old 01-21-2012, 06:28 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Refractor View Post
Thank you for the suggestion, though I finally managed to build my cross compiler successfully.
I used as examples the arch PKGBUILD scripts from this post with a few modifications: https://bbs.archlinux.org/viewtopic....988450#p988450
There is a well established piece: http://mingw-cross-env.nongnu.org/ - worked quite well when I tried it a couple of years ago.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross compiler building dejavih Linux From Scratch 8 02-25-2011 04:56 AM
Need help building x86_64 Cross compiler on x86 linux (Red Hat) torque_dwf Linux - Software 4 01-08-2009 03:37 AM
Question about building a Linux hosted, Mingw-targeted cross compiler tomdkat Linux - Software 2 12-12-2008 10:55 AM
building cross compiler, having issues moonlightcheese *BSD 1 09-13-2008 02:09 AM
Building cross-compiler gcc for powerpc-linux ccool Linux - General 3 09-17-2004 06:33 AM


All times are GMT -5. The time now is 09:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration