Cannot link from Code::Block. Help?

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
User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 79
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Cannot link from Code::Block. Help?

Post by Parduz » Thu Jun 18, 2015 12:44 pm

I have an already working c++ + wxWidgets app built in Eclipse, with wxWidgets built using MSYS.

Now i'd like to try different IDEs, like CodeLite and Code::Blocks, but when i tried them they did'nt work 'cause i was lacking a build.cfg file they wants.
So i tried a "clean" way, backupped the wxWidgets and build them again using MinGW32-make instead of MSYS.

Trying Code:Block now, i get a lot of "undefined reference" errors, and i can't understand what i've done or set wrong.
I'll try to give here all the related info:
Path to wxWidgets:

Code: Select all

    C:\SVILUPPO\TOOLS\wxWidgets
Path variable (the related part)

Code: Select all

    PATH=C:\SVILUPPO\TOOLS\MinGW\bin;C:\SVILUPPO\TOOLS\MinGW\libexec\gcc\mingw32\4.8.1;
Mingw v4.8.1, make version

Code: Select all

    C:\SVILUPPO\TOOLS\wxWidgets>mingw32-make -v
    GNU Make 3.82.90
    Built for i686-pc-mingw32
wxWidgets build command:

Code: Select all

    C:\SVILUPPO\TOOLS\wxWidgets\build\msw>mingw32-make -f makefile.gcc BUILD=debug UNICODE=1 SHARED=0 MONOLITHIC=1
Code::Block build log:

Code: Select all

    -------------- Build: Debug in MyProject (compiler: GNU GCC Compiler)---------------
   
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.cpp -o obj\Debug\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.o
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\fMainForm.cpp -o obj\Debug\src\fMainForm.o
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\GUI_MainForm.cpp -o obj\Debug\src\GUI_MainForm.o
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\My_Project.cpp -o obj\Debug\src\My_Project.o
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Prova_wxcrafter_bitmaps.cpp -o obj\Debug\src\Prova_wxcrafter_bitmaps.o
    mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp 
    
    mingw32-g++.exe -LC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib -o bin\Debug\MyProject.exe obj\Debug\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.o obj\Debug\src\fMainForm.o obj\Debug\src\GUI_MainForm.o obj\Debug\src\My_Project.o obj\Debug\src\Prova_wxcrafter_bitmaps.o obj\Debug\src\Utilities\Utilities.o  -mthreads  -lwxmsw30ud -lwxpngd -lwxjpegd -lwxtiffd -lwxzlibd -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `StartElementHnd':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:637: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `TextHnd':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:687: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `StartCdataHnd':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:702: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `CommentHnd':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:727: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `PIHnd':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:742: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `ZN13wxXmlDocument4LoadER13wxInputStreamRK8wxStringi':
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:813: undefined reference to `XML_ParserCreate'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:826: undefined reference to `XML_SetUserData'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:827: undefined reference to `XML_SetElementHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:828: undefined reference to `XML_SetCharacterDataHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:829: undefined reference to `XML_SetCdataSectionHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:830: undefined reference to `XML_SetCommentHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:831: undefined reference to `XML_SetProcessingInstructionHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:832: undefined reference to `XML_SetDefaultHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:833: undefined reference to `XML_SetUnknownEncodingHandler'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:840: undefined reference to `XML_Parse'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:843: undefined reference to `XML_GetErrorCode'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:843: undefined reference to `XML_ErrorString'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:846: undefined reference to `XML_GetCurrentLineNumber'
    C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:865: undefined reference to `XML_ParserFree'
    collect2.exe: error: ld returned 1 exit status
    Process terminated with status 1 (0 minute(s), 29 second(s))
    19 error(s), 2 warning(s) (0 minute(s), 29 second(s))
     
I also tried adding other libs i had to add when i built this code under arm-linux) in the linker settings, but these libraries files are not existing (i guess 'cause the MONOLITHIC option):

Code: Select all

    libwxmsw30ud_core.a
    libwxmsw30ud_html.a
    libwxmsw30ud_adv.a
    libwxbase30ud_xml.a
    libwxmsw30ud_richtext.a


In the end, i don't know what i should to finally link and debug my sources from Code::Block.

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

Re: Cannot link from Code::Block. Help?

Post by doublemax » Thu Jun 18, 2015 12:51 pm

The missing references should all be in the "expat" library. I don't know its exact name in your environment, but you should be able to find it with this information.
Use the source, Luke!

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 79
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Cannot link from Code::Block. Help?

Post by Parduz » Thu Jun 18, 2015 1:17 pm

... thanks!
It is "gcc_lib\libwxexpatd.a".

Now, to learn a bit.... how should i have know this? Where should have i looked for?
Basically..... how do you know it? :)

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

Re: Cannot link from Code::Block. Help?

Post by doublemax » Thu Jun 18, 2015 1:39 pm

Basically..... how do you know it?
From experience ;)

However, if you create a new wxWidgets project from scratch with Code:Blocks (or any similar IDE), i think these standard libraries are always added automatically. You only have to deal with this if you create a new project from scratch.

One way that often helps is to put one relevant error message into Google, e.g. ""undefined reference to `XML_GetCurrentLineNumber'"".
Use the source, Luke!

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 79
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Cannot link from Code::Block. Help?

Post by Parduz » Thu Jun 18, 2015 1:44 pm

doublemax wrote:
Basically..... how do you know it?
From experience ;)
:)
doublemax wrote:However, if you create a new wxWidgets project from scratch with Code:Blocks (or any similar IDE), i think these standard libraries are always added automatically. You only have to deal with this if you create a new project from scratch.
Nope. Code::Blocks added everything was already there, but not that one.
I then imported my existing sources.
doublemax wrote:One way that often helps is to put one relevant error message into Google, e.g. ""undefined reference to `XML_GetCurrentLineNumber'"".
Yep. That leaded me to recompile wxWidgets using MinGW32-make instead of the MSYS-based procedure i used for Eclipse, and a bunch of other unsuccesful tries. That's why today i wrote this question to StackOverflow and then here.

Thanks a lot.

Post Reply