User forums > Help

Problem Linking Gcc : A new wxwidget project

<< < (2/5) > >>

cyberkoa:

--- Quote from: mandrav ---
--- Quote ---The file you mentioned "libwxmsw242.a" is not exist , but I found that it there are 2 files named "libwxmsw.a" under c:\wxWindows-2.4.2\lib\release and c:\wxWindows-2.4.2\lib\debug respectively.

--- End quote ---

Add "c:\wxWindows-2.4.2\lib\release" to your linker dirs (or the debug version, whichever you prefer).
That's all that's needed.

HTH,
Yiannis.
--- End quote ---


I have added the c:\wxWindows-2.4.2\lib\release to my Linker Dirs .


--- Quote ---Then, in the link libraries, edit the "wxmsw242" library and change it to "wxmsw".
--- End quote ---


Do you mean that I need to rename the file libwxmsw.a to wxmsw ?
But the error message shown that cannot find wxmsw242 ..
C:\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe: cannot find -lwxmsw242

Anyway , I have tried to rename

 libwxmsw.a under  c:\wxWindows-2.4.2\lib\release
to
1. wxmsw
2. wxmsw242
3. wxmsw.a
4. wxmsw242.a

I still get the same error message ....  :(

mandrav:

--- Quote ---Do you mean that I need to rename the file libwxmsw.a to wxmsw ?
--- End quote ---

No...
In the project's (or target's) linker options page the dependency for wxmsw242 is listed. It's either in the form of "libwxmsw242.a" or "wxmsw242". Change this to "wxmsw"...

Yiannis.

cyberkoa:
Hi, thanks. I have changed the setting in the Build Options. And the linker manages to find the library . But now I face another linking problem .
"Undefined reference " , I try to look into the source code of app.cpp , and find the "InitCommonControl" function but I can't find. It seems like is a WINAPI .
   I have tried to recompile my wxwidgets but it still the same problem.
I have tried my best to solve , however, I have not much C++ debugging experience , it seems like out of my ability to solve this problem .

The following is my linking error


--- Quote ---mingw32-g++.exe   -L"C:\\MinGW\\lib"  -L"..\\MinGW\\lib" -L"..\\wxWindows-2.4.2\\lib" -L"..\\wxWindows-2.4.2\\contrib\\lib" -o "wxwindows.exe"   -L"C:\\MinGW\\lib"  -L"..\\MinGW\\lib" -L"..\\wxWindows-2.4.2\\lib" -L"..\\wxWindows-2.4.2\\contrib\\lib" ".objs\\main.o"     -lstdc++ -lgcc -lgdi32 -lcomdlg32 -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lwxmswd -mwindows
..\\wxWindows-2.4.2\\lib/libwxmswd.a(app.o)(.text+0x61a): In function `ZN5wxApp10InitializeEv':
c:/wxwindows-2.4.2/src/msw/../../src/msw/app.cpp:235: undefined reference to `InitCommonControls@0'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(app.o)(.text+0x624):c:/wxwindows-2.4.2/src/msw/../../src/msw/app.cpp:249: undefined reference to `OleInitialize@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(app.o)(.text+0x1160): In function `ZN5wxApp7CleanUpEv':
c:/wxwindows-2.4.2/src/msw/../../src/msw/app.cpp:561: undefined reference to `OleUninitialize@0'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(statbr95.o)(.text+0x215): In function `ZN11wxStatusBar6CreateEP8wxWindowilRK8wxString':
c:/wxwindows-2.4.2/src/msw/../../src/msw/statbr95.cpp:104: undefined reference to `CreateStatusWindowA@16'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(utils.o)(.text+0x10f): In function `Z17wxGetFullHostNamePci':
c:/wxwindows-2.4.2/src/msw/../../src/msw/utils.cpp:182: undefined reference to `WSAStartup@8'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(utils.o)(.text+0x140):c:/wxwindows-2.4.2/src/msw/../../src/msw/utils.cpp:186: undefined reference to `gethostname@8'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(utils.o)(.text+0x176):c:/wxwindows-2.4.2/src/msw/../../src/msw/utils.cpp:192: undefined reference to `gethostbyname@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(utils.o)(.text+0x19f):c:/wxwindows-2.4.2/src/msw/../../src/msw/utils.cpp:197: undefined reference to `gethostbyaddr@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(utils.o)(.text+0x1f8):c:/wxwindows-2.4.2/src/msw/../../src/msw/utils.cpp:207: undefined reference to `WSACleanup@0'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.text+0x998): In function `ZN12wxDropTarget8RegisterEm':
c:/wxwindows-2.4.2/src/msw/../../src/msw/ole/droptgt.cpp:330: undefined reference to `CoLockObjectExternal@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.text+0x9f2):c:/wxwindows-2.4.2/src/msw/../../src/msw/ole/droptgt.cpp:336: undefined reference to `RegisterDragDrop@8'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.text+0xa10):c:/wxwindows-2.4.2/src/msw/../../src/msw/ole/droptgt.cpp:338: undefined reference to `CoLockObjectExternal@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.text+0xa8d): In function `ZN12wxDropTarget6RevokeEm':
c:/wxwindows-2.4.2/src/msw/../../src/msw/ole/droptgt.cpp:352: undefined reference to `RevokeDragDrop@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.text+0xadc):c:/wxwindows-2.4.2/src/msw/../../src/msw/ole/droptgt.cpp:358: undefined reference to `CoLockObjectExternal@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.data+0x0): In function `ZN12wxDataFormataSERKS_':
c:/wxwindows-2.4.2/src/msw/../../include/wx/msw/ole/dataform.h: undefined reference to `IID_IUnknown'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(droptgt.o)(.data+0x4):c:/wxwindows-2.4.2/src/msw/../../include/wx/msw/ole/dataform.h: undefined reference to `IID_IDropTarget'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(spinbutt.o)(.text+0x2e1): In function `ZN12wxSpinButton6CreateEP8wxWindowiRK7wxPointRK6wxSizelRK8wxString':
c:/wxwindows-2.4.2/src/msw/../../src/msw/spinbutt.cpp:122: undefined reference to `CreateUpDownControl@48'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x177): In function `ZN11wxImageList6CreateEiibi':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:99: undefined reference to `ImageList_Create@20'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x200): In function `ZN11wxImageListD2Ev':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:113: undefined reference to `ImageList_Destroy@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x25e): In function `ZN11wxImageListD1Ev':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:113: undefined reference to `ImageList_Destroy@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x2bc): In function `ZN11wxImageListD0Ev':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:113: undefined reference to `ImageList_Destroy@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x354): In function `ZNK11wxImageList13GetImageCountEv':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:127: undefined reference to `ImageList_GetImageCount@4'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x3a3): In function `ZNK11wxImageList7GetSizeEiRiS0_':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:135: undefined reference to `ImageList_GetIconSize@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x440): In function `ZN11wxImageList3AddERK8wxBitmapS2_':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:149: undefined reference to `ImageList_Add@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x4aa): In function `ZN11wxImageList3AddERK8wxBitmapRK8wxColour':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:169: undefined reference to `ImageList_AddMasked@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x4f9): In function `ZN11wxImageList3AddERK6wxIcon':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:184: undefined reference to `ImageList_ReplaceIcon@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x56e): In function `ZN11wxImageList7ReplaceEiRK8wxBitmapS2_':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:205: undefined reference to `ImageList_Replace@16'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x616): In function `ZN11wxImageList7ReplaceEiRK6wxIcon':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:221: undefined reference to `ImageList_ReplaceIcon@12'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x69f): In function `ZN11wxImageList6RemoveEi':
c:/wxwindows-2.4.2/src/msw/../../src/msw/imaglist.cpp:237: undefined reference to `ImageList_Remove@8'
..\\wxWindows-2.4.2\\lib/libwxmswd.a(imaglist.o)(.text+0x712): In function `ZN11wxImageList9RemoveAllEv':
Process terminated with status 1 (0 minutes, 55 seconds)
29 errors, 0 warnings
--- End quote ---

Anonymous:
Hi.

I had the same problem as you but I managed to solve it :) Here is how!

The main problem is that the linker doesn't find some librairies it needs in order to link your project.

Usually, when you're linking a wxWidgets app, you need to add this options to the linker (theses options are depending of which wx functions and classes you use, so you perhaps need to add some):
-lwinspool
-lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32
-lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid

I tried to add this in the "linker options" control (right click on your project, "Build Options"->"Linker options"), but this didn't work.

Instead, add manually the libraires in the "link librairies" box at the left (right click on your project, "Build Options"->"Linker options"). Click on "Add" and go to "C:\Program Files\CodeBlocks\lib" directory (assuming you did a standard installation).

Here there is a lot of files whose name is starting by "lib". Select for exemple libwinspool.a (which corresponds to "-lwinspool" in the command line). Click on ok. Now you can edit the full path of the librairy.
THERE IS A BUG IN CODE::BLOCK 1.0beta6: if there is a space in the name of a librairy, the command line is misinterpreted!!!! (please developpers, add " ou ' before and after each name!!)
So we need to act like 10 years ago: change "Program Files" by "Progra~1". Click finally on ok.

You need to do this for all the librairies you need (sorry). If uyou have undefined symbols, do a search on google: it will give you (generally) the MSDN page corresponding to the function. Here you can find which librairy you need to link.

Evan Meakyl

cyberkoa:
hi , thank you very much, finally I manage to compile and run my program properly.

Even though I follow your method to add the linker options , I still face a problem when running the output execute file.

It gives me some error telling me that the library version is different (debug) kind of message. However, later I solve it myself by linking to the non-debug version of libmsw library.

I am very happy because I manage to start my wx-widgets framework programming life .. hurray

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version