User forums > Help

Problem with linking libraries

<< < (2/3) > >>

rem:
Finally I succeed to link the program. I've changed the Compiler -> Compiler Options -> Other -> Build method -> Work with Makefiles (GNU "make" is required). I've also changed the libraries from:

-lwxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

to
 wxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

It's because the code::blocks probably adds -l on the beggining and if you do that to the linked libraries will look like this

-l-lwxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

Thanks for the help.

rem:
I'm really confused about the linking.

I add this libraries
 wxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

and I get this:

Project   : wxWidgets application
Compiler  : GNU GCC Compiler (using GNU "make")
Directory : C:\Dev-Cpp\Projects\5\
--------------------------------------------------------------------------------
mingw32-g++.exe  -LC:/Program\ Files/CodeBlocks/lib -LC:/Dev-Cpp/lib -o C:/Dev-Cpp/Projects/5/wxWidgets.exe .objs/main.o .objs/app.o      -l-lwxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwxmsw26 -lwxmsw26_gl -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregex -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -mwindows
C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -l-lwxmsw26
collect2: ld returned 1 exit status
make.exe: *** [C:/Dev-Cpp/Projects/5/wxWidgets.exe] Error 1
Process terminated with status 1 (0 minutes, 0 seconds)
 
Why there is -l-lwxmsw26 if I add wxmsw26 in the linker libraries.

DreadNot:
Put -l back on wxmsw26.  I looks like you don't have directory paths setup for the linker properly.  It should be "C:\Dev-Cpp\lib" and other such directories.  wxWidgets are generally in "...somewhere\wxWidgets-2.6.x\lib\gcc_dll" or some such place.

mandrav:
If you add the libs in the "Link libraries" box, you don't have to use "-l".
If you put it in "Other linker options" you must put "-l".

Also, if possible, use the "direct-mode" instead of "make". there are some known bugs with "make" and I 'm working on them.

Yiannis.

rem:
Project   : Project1
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Dev-Cpp\Projects\3\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe   -Wall -pg -g -fno-rtti -fno-exceptions -fno-pcc-struct-return -fstrict-aliasing -Wall -D__WXMSW__ -D__GNUWIN32__ -D__WIN95__  -Wall    -I"C:\Program Files\CodeBlocks\include" -IC:\Dev-Cpp\include -c myapp.cpp -o .objs\myapp.o
mingw32-g++.exe   -Wall -pg -g -fno-rtti -fno-exceptions -fno-pcc-struct-return -fstrict-aliasing -Wall -D__WXMSW__ -D__GNUWIN32__ -D__WIN95__  -Wall    -I"C:\Program Files\CodeBlocks\include" -IC:\Dev-Cpp\include -c main.cpp -o .objs\main.o
mingw32-g++.exe    -L"C:\Program Files\CodeBlocks\lib" -LC:\Dev-Cpp\lib -o C:\Dev-Cpp\Projects\3\Project1.exe .objs\myapp.o .objs\main.o    -pg -lgmon      -l"wxmsw26 wxmsw26_gl wxtiff wxjpeg wxpng wxzlib wxregex wxexpat kernel32 user32 gdi32 comdlg32 winspool winmm shell32 comctl32 ole32 oleaut32 uuid rpcrt4 advapi32 wsock32" -mwindows
C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lwxmsw26 wxmsw26_gl wxtiff wxjpeg wxpng wxzlib wxregex wxexpat kernel32 user32 gdi32 comdlg32 winspool winmm shell32 comctl32 ole32 oleaut32 uuid rpcrt4 advapi32 wsock32
collect2: ld returned 1 exit status
Process terminated with status 1 (1 minutes, 15 seconds)
0 errors, 0 warnings
 

 
All libriaries linked in this project are in one directory
C:\Dev-cpp\lib

And it is added to the linker directories

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version