You are not logged in.

#1 2012-03-22 02:56:10

rh995
Member
Registered: 2012-03-09
Posts: 76

compiling c++ files for windows

I have a c++ program that I would like to compile windows binaries for. I have tried installing mingw32-gcc, and using g++, but when I run the binaries (in wine or from windows), I get errors that certain .dll files are not found. Is there additional configuration needed to set up mingw32? Or should I be using a completely separate compiler. Thanks in advance!

Offline

#2 2012-03-22 05:15:16

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: compiling c++ files for windows

Which .dll files?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-03-22 23:31:02

rh995
Member
Registered: 2012-03-09
Posts: 76

Re: compiling c++ files for windows

ewaller wrote:

Which .dll files?

libgcc_s_sjlj-1.dll

Offline

#4 2012-03-23 00:10:33

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: compiling c++ files for windows

Well, depending on how you compile, you'll have to get the mingw support DLLs over there too, like libgcc for instance. There must be some documentation on the mingw site for installing apps on Windows.

Offline

#5 2012-03-23 02:34:05

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: compiling c++ files for windows

Grrr.  It used to work on my system (I think).  I have a gcc program that uses wxWidgets that I know that I cross compiled and placed on source forge, but I will be darned if I can wake it work now.  It is possible that I did it  with a Genoo system hmm

I'll get back to you...

Edit:  Do me a favor, grab http://sourceforge.net/projects/pdp1spa … p/download and see if it runs for you.  That archive contains the mingw10.dll
I promise the file is benign.  It is a port of SpaceWar (The first video game ever), which runs on a PDP-1 emulator.  The Linux version is in the AUR.

Last edited by ewaller (2012-03-23 03:10:28)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2012-03-23 03:32:10

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: compiling c++ files for windows

Here is "Hello World"

ewaller@odin:~ 1029 %cd test 
ewaller@odin:~/test 1030 %ls  
hello.c
ewaller@odin:~/test 1031 %cat hello.c 

#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
  printf ("Hello World\n");
}
ewaller@odin:~/test 1032 %i486-mingw32-gcc hello.c -o hello.exe
ewaller@odin:~/test 1033 %ls                                   
hello.c  hello.exe
ewaller@odin:~/test 1034 %wine hello.exe                       
Hello World
ewaller@odin:~/test 1035 %

Last edited by ewaller (2012-03-23 03:34:46)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2012-03-23 04:01:30

rh995
Member
Registered: 2012-03-09
Posts: 76

Re: compiling c++ files for windows

ewaller wrote:

Here is "Hello World"

ewaller@odin:~ 1029 %cd test 
ewaller@odin:~/test 1030 %ls  
hello.c
ewaller@odin:~/test 1031 %cat hello.c 

#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
  printf ("Hello World\n");
}
ewaller@odin:~/test 1032 %i486-mingw32-gcc hello.c -o hello.exe
ewaller@odin:~/test 1033 %ls                                   
hello.c  hello.exe
ewaller@odin:~/test 1034 %wine hello.exe                       
Hello World
ewaller@odin:~/test 1035 %

Works perfectly, even when substituting g++ for gcc. My problems occur, however, when compiling other things, I don't know why it is different.

[ray@rays-computer programming]$ cd YetiHack/src/
[ray@rays-computer src]$ ls                                                    
Makefile  YetiHack.cpp  yeti.cpp
[ray@rays-computer src]$ i486-mingw32-g++ YetiHack.cpp yeti.cpp -o yetihack.exe -I../include -lpdcurses
[ray@rays-computer src]$ wine yetihack.exe
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\ray\\Documents\\programming\\YetiHack\\src\\yetihack.exe") not found
err:module:import_dll Library pdcurses.dll (which is needed by L"Z:\\home\\ray\\Documents\\programming\\YetiHack\\src\\yetihack.exe") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\ray\\Documents\\programming\\YetiHack\\src\\yetihack.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\ray\\Documents\\programming\\YetiHack\\src\\yetihack.exe" failed, status c0000135
[ray@rays-computer src]$ 

Offline

#8 2012-03-23 04:13:31

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: compiling c++ files for windows

ewaller@odin:~/test[1] 1040 %locate libgcc_s_sjlj-1.dll                      
/home/ewaller/Dropbox/libgcc_s_sjlj-1.dll
/home/ewaller/Dropbox/wxwidgetsprojects/spacewar/src/libgcc_s_sjlj-1.dll
/home/ewaller/devel/wxwidgetsprojects/spacewar/src/libgcc_s_sjlj-1.dll
/usr/i486-mingw32/bin/libgcc_s_sjlj-1.dll
/usr/i486-mingw32/lib/libgcc_s_sjlj-1.dll
ewaller@odin:~/test 1041 %pacman -Qo /usr/i486-mingw32/bin/libgcc_s_sjlj-1.dll
/usr/i486-mingw32/bin/libgcc_s_sjlj-1.dll is owned by mingw32-gcc 4.6.2-1
ewaller@odin:~/test 1042 %pacman -Qo /usr/i486-mingw32/lib/libgcc_s_sjlj-1.dll
/usr/i486-mingw32/lib/libgcc_s_sjlj-1.dll is owned by mingw32-gcc 4.6.2-1
ewaller@odin:~/test 1043 %
ewaller@odin:~/test 1054 %locate libstdc++-6.dll                          
/home/ewaller/Dropbox/libstdc++-6.dll
/home/ewaller/Dropbox/wxwidgetsprojects/spacewar/src/libstdc++-6.dll
/home/ewaller/devel/wxwidgetsprojects/spacewar/src/libstdc++-6.dll
/usr/i486-mingw32/bin/libstdc++-6.dll
/usr/i486-mingw32/lib/libstdc++-6.dll
ewaller@odin:~/test 1055 %pacman -Qo /usr/i486-mingw32/bin/libstdc++-6.dll
/usr/i486-mingw32/bin/libstdc++-6.dll is owned by mingw32-gcc 4.6.2-1
ewaller@odin:~/test 1056 %pacman -Qo /usr/i486-mingw32/lib/libstdc++-6.dll
/usr/i486-mingw32/lib/libstdc++-6.dll is owned by mingw32-gcc 4.6.2-1
ewaller@odin:~/test 1057 %
waller@odin:~/test 1047 %locate pdcurses.dll
ewaller@odin:~/test[1] 1048 %

Edit: Okay, I botched that post.. I'm fixing it.... There, that is better smile

Edit: The plot thickens...

ewaller@odin:~/test 1070 %pkgfile pdcurses.dll
ewaller@odin:~/test 1071 %

Last edited by ewaller (2012-03-23 04:35:19)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#9 2012-03-23 11:28:28

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: compiling c++ files for windows

I had the same problem last time, and the problem seems to be the dynamic link of libraries.
Try to compile a static version. This will result in a larger binary, but it is independent. This works in my case, where the program has to work with serial ports on windows.

I cross-compile it like this

/usr/bin/i486-mingw32-g++ -static-libgcc -static-libstdc++ -L . <code> -o <output.exe>

works even with wine.

Offline

#10 2012-03-26 03:05:24

rh995
Member
Registered: 2012-03-09
Posts: 76

Re: compiling c++ files for windows

linux-ka wrote:

I had the same problem last time, and the problem seems to be the dynamic link of libraries.
Try to compile a static version. This will result in a larger binary, but it is independent. This works in my case, where the program has to work with serial ports on windows.

I cross-compile it like this

/usr/bin/i486-mingw32-g++ -static-libgcc -static-libstdc++ -L . <code> -o <output.exe>

works even with wine.

First, the bad news. For me, it doesn't work with wine, possibly a side effect of using pdcurses, but on windows, it works great. Perfectly. Thank you, I don't know what I would have done without you.

Edit: Is there any way to get .dll files I have on hand compiled in to the binary so I don't have to release them as separate files?

Last edited by rh995 (2012-03-26 03:14:20)

Offline

#11 2012-03-26 13:11:57

linux-ka
Member
From: ADL
Registered: 2010-05-07
Posts: 232

Re: compiling c++ files for windows

hm, maybe just try pure -L <path/to/your/self-compiled-dll> -static . But I don't know whether this really includes self-written/-compiled .dll files for static compilation.

Offline

#12 2013-03-30 14:45:20

ivan.kolmycheck
Member
Registered: 2013-03-30
Posts: 2

Re: compiling c++ files for windows

linux-ka wrote:

I cross-compile it like this

/usr/bin/i486-mingw32-g++ -static-libgcc -static-libstdc++ -L . <code> -o <output.exe>

Thank you very-very much, it works for me.

Last edited by ivan.kolmycheck (2013-03-30 14:49:59)

Offline

Board footer

Powered by FluxBB