Linker Issues (libfile without prefix)

CodeLite installation/troubleshooting forum
starger
CodeLite Curious
Posts: 1
Joined: Sat Jun 17, 2017 3:20 pm
Genuine User: Yes
IDE Question: c++
Contact:

Linker Issues (libfile without prefix)

Post by starger »

Hello,
I plan to move to CodeLite, so I currently do my first tests at the moment.
Everything looks good and feels good until now, but there is one issue:

The first small "Hello World" was ok, so I decided to try something with Dislin (plotting library).
Everything went fine until the compilation. So here is my first Log:

C:\Windows\system32\cmd.exe /C C:/GNU/MinGW/bin/mingw32-make.exe -j2 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ test_dislin_ide - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'D:/Programming/C/Codelite/Workspace/test_dislin_ide'
C:/GNU/MinGW/bin/g++.exe -c "D:/Programming/C/Codelite/Workspace/test_dislin_ide/main.cpp" -g -O0 -Wall -o ./Debug/main.cpp.o -IC:\LIBS\dislin_mg
C:/GNU/MinGW/bin/g++.exe -o ./Debug/test_dislin_ide @"test_dislin_ide.txt" -LC:\LIBS\dislin_mg -ldiscpp51 -lgdi32 -luser32 -lopengl32
c:/gnu/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -ldiscpp51
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/test_dislin_ide] Error 1
test_dislin_ide.mk:78: recipe for target 'Debug/test_dislin_ide' failed
mingw32-make.exe: *** [All] Error 2
mingw32-make.exe[1]: Leaving directory 'D:/Programming/C/Codelite/Workspace/test_dislin_ide'
Makefile:4: recipe for target 'All' failed
====1 errors, 0 warnings====

I could figure out that the reason was the missing lib-prefix of the library file. So renaming "discpp51.a" to "libdiscpp.a" fixed the issue.
But this was just a workaround.

Normally there are 2 options in this case:
1. Give the full path to the library. This actually fails because of the "-l" prefix in the gcc command.
2. ":discpp51.a" (without "") in the libraries column should be the most common way but this gives the same error.

So I wrote the linker options by hand ( -l:discpp.a -lgdi32 -luser32 -lopengl32 ) and shipped them to the column "Options" (Settings -> Global Settings -> Linker) and everything was fine.
But I am not sure if this is the correct solution (it would make the column "Libraries" obsolete).

So: Did I something wrong here? Is this is a bug? Is this the solution as it should be?

Thanks in advance,
starger.

My CodeLite:
CodeLite 10.0.5 - Weekly Build - Windows 7 - AMD64 (not self compiled)
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Linker Issues (libfile without prefix)

Post by eranif »

starger wrote:I could figure out that the reason was the missing lib-prefix of the library file. So renaming "discpp51.a" to "libdiscpp.a" fixed the issue.
But this was just a workaround.
No, this is how the linker works... it needs the 'lib' prefix
Settings -> Global Settings -> Linker)
Where is that? I don't think there is such a path somewhere in CodeLite


If you have a unique string that you want to pass to the linker, add it in the linker options:
Project settings->Linker->Linker options
Here you can pass any strings to the linker, separated with semi-colons (";") the string will be passed as-is to the linker without adding "-l" etc
Make sure you have read the HOW TO POST thread
Post Reply