Linking problems (MinGW, Eclipse CDK) Topic is solved

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
FF0084
In need of some credit
In need of some credit
Posts: 5
Joined: Thu Nov 01, 2012 7:23 pm

Linking problems (MinGW, Eclipse CDK)

Post by FF0084 » Thu Nov 01, 2012 7:36 pm

Like many people do, I too have linking problems - the errors with "undefined reference" phrase. I've installed wxPack, included all of the libraries necessary and yet I'm missing something. Like in the title - I'm using MinGW and Eclipse CDK to compile my projects.

Here's a command passed to the linker at the end of a compilation process:

Code: Select all

g++ -LC:\wxWidgets2.8\lib\gcc_lib -o WXTest src\HelloWorldApp.o -lwxmsw28_core -lwxbase28 -lwxbase28_net -lwxbase28_odbc -lwxbase28_xml -lwxexpat -lwxjpeg -lwxmsw28 -lwxmsw28_adv -lwxmsw28_aui -lwxmsw28_dbgrid -lwxmsw28_gl -lwxmsw28_html -lwxmsw28_media -lwxmsw28_qa -lwxmsw28_richtext -lwxmsw28_xrc -lwxpng -lwxregex -lwxtiff -lwxzlib
Here's the very beginning of the linking errors I get:

Code: Select all

C:\wxWidgets2.8\lib\gcc_lib/libwxmsw28_core.a(corelib_window.o):window.cpp:(.text+0x1006): undefined reference to `[email protected]'
C:\wxWidgets2.8\lib\gcc_lib/libwxmsw28_core.a(corelib_window.o):window.cpp:(.text+0x101a): undefined reference to `[email protected]'
C:\wxWidgets2.8\lib\gcc_lib/libwxmsw28_core.a(corelib_window.o):window.cpp:(.text+0x102d): undefined reference to `[email protected]'
C:\wxWidgets2.8\lib\gcc_lib/libwxmsw28_core.a(corelib_window.o):window.cpp:(.text+0x1077): undefined reference to `[email protected]'
... and there are hundreds of those. Even compiling the wxWidgets myself didn't solve the problem. I've read so many tutorials about making a project, but each one of them presents a different way to deal with it, half of which I completely do not understand. Why simple linking of libraries is not enough obviously? What am I missing?

Thomas

User avatar
doublemax
Moderator
Moderator
Posts: 15083
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking problems (MinGW, Eclipse CDK)

Post by doublemax » Thu Nov 01, 2012 8:54 pm

The undefined references you listed are from the native Windows libs. I don't see them in your command line.

I usually don't use MingW, but googling told me that you probably have to add "-mwindows" to the command line.
Use the source, Luke!

FF0084
In need of some credit
In need of some credit
Posts: 5
Joined: Thu Nov 01, 2012 7:23 pm

Re: Linking problems (MinGW, Eclipse CDK)

Post by FF0084 » Thu Nov 01, 2012 11:16 pm

Thank you so much! I've added this flag to the linker settings and the number of undefined references has been reduced greatly. I googled the references and added yet few libraries to it and it had worked! I wonder if there's another magic "flag" which would add these libs automatically.

Here's my final linker command line:

Code: Select all

g++ -LC:\wxWidgets2.8\lib\gcc_lib -mwindows -o WXTest src\HelloWorldApp.o -lwxbase28_net -lwxbase28_odbc -lwxbase28_xml -lwxexpat -lwxjpeg -lwxmsw28 -lwxmsw28_adv -lwxmsw28_aui -lwxmsw28_dbgrid -lwxmsw28_gl -lwxmsw28_html -lwxmsw28_media -lwxmsw28_qa -lwxmsw28_richtext -lwxmsw28_xrc -lwxpng -lwxregex -lwxtiff -lwxzlib -lwxmsw28_core -lwxbase28 -luuid -loleaut32 -lole32 -lwinspool -lcomctl32
I've added the following libraries: uuid, oleaut32, ole32, winspool, comctl32. Tomorrow I'll check which wx libs are redutant and get rid of them as well.

Cheers!

User avatar
doublemax
Moderator
Moderator
Posts: 15083
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking problems (MinGW, Eclipse CDK)

Post by doublemax » Fri Nov 02, 2012 1:30 am

With cygwin you'd could wx-config like in Linux. Or with plain MingW you could use a makefile from one of the wxWidgets samples as a start for your own makefile.

Did you see this?
http://wiki.wxwidgets.org/Eclipse#Windows
Use the source, Luke!

FF0084
In need of some credit
In need of some credit
Posts: 5
Joined: Thu Nov 01, 2012 7:23 pm

Re: Linking problems (MinGW, Eclipse CDK)

Post by FF0084 » Fri Nov 02, 2012 10:16 am

I must say I don't quite understand it. I've been using make files for compiling libraries only for use in my apps. For compiling executables I'm using IDE. I tried to compile my app with a modified make file from a sample, but it just won't work. It's too complicated for me, there's too much things to be altered. Are there any advantages of using make files instead of g++ when compiling an executable anyway?

Sarah Keys
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Jan 02, 2014 3:55 pm

Re: Linking problems (MinGW, Eclipse CDK)

Post by Sarah Keys » Thu Jan 02, 2014 4:22 pm

FF0084 wrote:I must say I don't quite understand it. I've been using make files for compiling libraries only for use in my apps. For compiling executables I'm using IDE. I tried to compile my app with a modified make file from a sample, but it just won't work. It's too complicated for me, there's too much things to be altered. Are there any advantages of using make files instead of g++ when compiling an executable anyway?
I don't understand your question. Make files are "scripts" where you define a set of routines to be executed .. When you use make files to compile , you usually set all the dependencies you need (to avoid the error you have posted in this thread for example) and all the steps you need to compile your code. As for compiling, make files can invoke g++ to do the compiling … so make files and g++ are not different alternatives , but 2 very different things :)

Post Reply