/usr/bin/ld: cannot find
Solution 1
Add -L/opt/lib
to your compiler parameters, this makes the compiler and linker search that path for libcalc.so
in that folder.
Solution 2
When you make the call to gcc it should say
g++ -Wall -I/home/alwin/Development/Calculator/ -L/opt/lib main.cpp -lcalc -o calculator
not -libcalc.so
I have a similar problem with auto-generated makes.
You can create a soft link from your compile directory to the library directory. Then the library becomes "local".
cd /compile/directory
ln -s /path/to/libcalc.so libcalc.so
Solution 3
You need to add -L/opt/lib
to tell ld
to look there for shared objects.
Solution 4
@Alwin Doss You should provide the -L option before -l. You would have done the other way round probably. Try this :)
Related videos on Youtube
Alwin Doss
I am a tech freak, not to mention I call myself a FOSSite (A Guy who belongs to FOSS movement - Free and Open Source software). Apart from me being a tech freak am passionately in love with Jesus, which got me so interested in FOSS where people share with out greed.
Updated on July 09, 2022Comments
-
Alwin Doss almost 2 years
I created a
.so
file and put it in the location/opt/lib
and added this path toLD_LIBRARY_PATH
now after this when I try to compile my main program with the following command:g++ -Wall -I/home/alwin/Development/Calculator/ main.cpp -lcalc -o calculator
I get the following error:
/usr/bin/ld: cannot find -lcalc collect2: ld returned 1 exit status
Can someone help me with this. I created the shared library using the code blocks IDE