Compiling under windows

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Compiling under windows

Post by AUser » Sat Aug 16, 2008 7:48 am

Edit: I am compiling under Windows XP Professional SP2

Hello,

I have written a small app, that uses several libraries, one of which is wx. I wrote this under Fedora linux & mac OSX, where it works well. When I wanted to compile it under windows, I have run into a few more problems.

I have succesfully compiled wxwidgets as a static library, and am attempting to compile my app against the library and include files -- however with limited success.

Due to the other libraries I use, I have to use the gcc compiler , as the other libraries (eg, gsl, but also others) require this.

So onwards I went. I have written a makefile, cutting and pasting the output from wx-config --cflags, and then editing all the \'s to \\s (prevent shell excaping; I tried using sed, but there is a problem with windows' backtick operator :( ). In this way I have been able to get either make (which is using the Dev-c++ make that I have installed) using windows "cmd.exe" or the cygwin make, using the cygwin bash prompt.

Now the problem I get is this: If i attempt to compile using the cygwin bash prompt, I get
(incomplete output, I can post the complete output if needed)
g++ -c -mthreads -DHAVE_W32API_H -D__WXMSW__ -IC:\\wxWidgets-2.8.8\\lib\\gcc_lib\\msw -IC:\\wxWidgets-2.8.8\\include -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -IC:\\cygwin\\usr\\include -o MainFrame.o MainFrame.cpp
In file included from C:/wxWidgets-2.8.8/include/wx/wx.h:15,
from wxprec.h:2,
from wxprec-proxy.h:7,
from MainFrame.h:3,
from MainFrame.cpp:3:
C:/wxWidgets-2.8.8/include/wx/defs.h:771:10: #error "Unsupported Windows version"
If i attempt to compile using cmd I get (incomplete output -- I can post the complete output if needed)
g++ -c -mthreads -DHAVE_W32API_H -D__WXMSW__ -IC:\\wxWidgets-2.8.8\\lib\\gcc_li
b\\msw -IC:\\wxWidgets-2.8.8\\include -Wno-ctor-dtor-privacy -pipe -fmessage-len
gth=0 -IC:\\cygwin\\usr\\include -o MainFrame.o MainFrame.cpp
In file included from C:/wxWidgets-2.8.8/include/wx/string.h:55,
from C:/wxWidgets-2.8.8/include/wx/memory.h:16,
from C:/wxWidgets-2.8.8/include/wx/object.h:20,
from C:/wxWidgets-2.8.8/include/wx/wx.h:16,
from wxprec.h:2,
from wxprec-proxy.h:7,
from MainFrame.h:3,
from MainFrame.cpp:3:
C:/wxWidgets-2.8.8/include/wx/buffer.h: In constructor `wxWCharBuffer::wxWCharBu
ffer(const wchar_t*)':
C:/wxWidgets-2.8.8/include/wx/buffer.h:134: error: `_wcsdup' undeclared (first u
se this function)
C:/wxWidgets-2.8.8/include/wx/buffer.h:134: error: (Each undeclared identifier i
s reported only once for each function it appears in.)
C:/wxWidgets-2.8.8/include/wx/buffer.h: In member function `wxWCharBuffer& wxWCh
arBuffer::operator=(const wchar_t*)':
C:/wxWidgets-2.8.8/include/wx/buffer.h:134: error: `_wcsdup' undeclared (first u
se this function)


I have spent quite a while trying to work out how to solve this problem, as I would sorely like to be able to create a windows binary of my program -- any help is most appreciated.[/quote]

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sat Aug 16, 2008 6:16 pm

Msys seems to work wonders, and IMO, should be the only tool used to compile wxWidgets on windows if using mingw/gcc.

FlyingIsFun1217

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Sun Aug 17, 2008 2:58 am

I have msys a whirl, but still I have the same problem. The interesting thing is that I have no problem compiling the sample application, or compiling my program on other (non-MS) systems.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Thu Aug 21, 2008 9:36 pm

AUser wrote:(non-MS) systems.
And how are you compiling on those other platforms? Through the terminal, perhaps using ./configure and make && make install?

FlyingIsFun1217

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Sat Aug 23, 2008 5:09 am

On my fedora system it is a binary package, i install it (wxWidgets-devel) with yum. On my mac I use fink, or I can just use the older wx that comes with the mac -- or I can compile the latest with ./configure && make && make install. All of these work.

When I actually get to the stage of compiling my app under non-MS platforms I have my own custom makefiles to do the job, which rely on `wx-config`.

Under windows I have to manually write out the output from wx-config, as sed has a problem with WXCPPFLAGS=`wx-config --cflags | sed 's#\\#\\\\#g'` (yes wx-config is in my path)

Windows and I just don't like one another.

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Sun Aug 24, 2008 2:10 pm

Update for internet searchers.

I appear to have narrowed down, but not solved, the problem.

By adding the following linker flag, I can prevent the sample apps from compiling.
-I/cygdrive/c/cygwin/usr/include/
The reason being that I have caused the following (below) to occur (diff shown), output from gcc -H ....

It appears that Wx apps will not compile against the normal cygwin headers, but only against the MinGW version. This is a problem, as my app requires libraries that need POSIX components, for example pthreads. So if I don't include the above GCC flag, my app wont compile because I dont have POSIX functions that I need... If i do then WX wont compile!

If my analysis of the situation is correct -- What to do to solve this dilemma?
16,20c16,25
< .... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/assert.h
< .... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/limits.h
< ..... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/syslimits.h
< ...... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/limits.h
< ....... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/limits.h
---
> .... /cygdrive/c/cygwin/usr/include/assert.h
> ..... /cygdrive/c/cygwin/usr/include/_ansi.h
> ...... /cygdrive/c/cygwin/usr/include/newlib.h
> ...... /cygdrive/c/cygwin/usr/include/sys/config.h
> ....... /cygdrive/c/cygwin/usr/include/machine/ieeefp.h
> ....... /cygdrive/c/cygwin/usr/include/cygwin/config.h
> .... /cygdrive/c/cygwin/usr/include/limits.h
> ..... /cygdrive/c/cygwin/usr/include/features.h
> ...... /cygdrive/c/cygwin/usr/include/sys/cdefs.h
> ...... /cygdrive/c/cygwin/usr/include/sys/features.h
22c27
< ..... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/stdio.h
---
> ..... /cygdrive/c/cygwin/usr/include/stdio.h
25c30,36
< ...... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/sys/types.h
---
> ...... /cygdrive/c/cygwin/usr/include/sys/reent.h
> ....... /cygdrive/c/cygwin/usr/include/_ansi.h
> ....... /cygdrive/c/cygwin/usr/include/sys/_types.h
> ........ /cygdrive/c/cygwin/usr/include/sys/lock.h
> ........ /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h
> ...... /cygdrive/c/cygwin/usr/include/sys/types.h
> ....... /cygdrive/c/cygwin/usr/include/machine/_types.h
26a38,43
> ....... /cygdrive/c/cygwin/usr/include/machine/types.h
> ....... /cygdrive/c/cygwin/usr/include/cygwin/types.h
> ........ /cygdrive/c/cygwin/usr/include/sys/sysmacros.h
> ........ /cygdrive/c/cygwin/usr/include/stdint.h
> ........ /cygdrive/c/cygwin/usr/include/endian.h
> ...... /cygdrive/c/cygwin/usr/include/sys/stdio.h
28c45
< ..... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/wchar.h
---
> ..... /cygdrive/c/cygwin/usr/include/wchar.h
30,33d46
< ...... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/wctype.h
< ....... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h
< ...... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/stdint.h
< ....... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h
35,37c48
< ..... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/string.h
< ...... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h
< ..... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/ctype.h
---
> ..... /cygdrive/c/cygwin/usr/include/string.h
38a50,51
> ...... /cygdrive/c/cygwin/usr/include/sys/string.h
> ..... /cygdrive/c/cygwin/usr/include/ctype.h
41,44c54,57
< ... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/unistd.h
< .... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/io.h
< .... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/process.h
< .... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/getopt.h
---
> ... /cygdrive/c/cygwin/usr/include/unistd.h
> .... /cygdrive/c/cygwin/usr/include/sys/unistd.h
> ..... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/stddef.h
> ..... /cygdrive/c/cygwin/usr/include/getopt.h
49,50c62
< ..... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/limits.h
< ..... /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include/stdlib.h
---
> ..... /cygdrive/c/cygwin/usr/include/stdlib.h
51a64,67
> ...... /cygdrive/c/cygwin/usr/include/machine/stdlib.h
> ...... /cygdrive/c/cygwin/usr/include/alloca.h
> ...... /cygdrive/c/cygwin/usr/include/cygwin/stdlib.h
> ....... /cygdrive/c/cygwin/usr/include/cygwin/wait.h
52a69,78
> In file included from /cygdrive/c/wxWidgets-2.8.8/include/wx/string.h:55,
> from /cygdrive/c/wxWidgets-2.8.8/include/wx/memory.h:16,
> from /cygdrive/c/wxWidgets-2.8.8/include/wx/object.h:20,
> from /cygdrive/c/wxWidgets-2.8.8/include/wx/wx.h:16,
> from ./minimal.cpp:30:
> /cygdrive/c/wxWidgets-2.8.8/include/wx/buffer.h: In constructor `wxWCharBuffer::wxWCharBuffer(const wchar_t*)':
> /cygdrive/c/wxWidgets-2.8.8/include/wx/buffer.h:134: error: `_wcsdup' undeclared (first use this function)
> /cygdrive/c/wxWidgets-2.8.8/include/wx/buffer.h:134: error: (Each undeclared identifier is reported only once for each function it appears in.)
> /cygdrive/c/wxWidgets-2.8.8/include/wx/buffer.h: In member function `wxWCharBuffer& wxWCharBuffer::operator=(const wchar_t*)':
> /cygdrive/c/wxWidgets-2.8.8/include/wx/buffer.h:134: error: `_wcsdup' undeclared (first use this function)
66d91
< ......... /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/limits.h

Post Reply