Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: noweare on September 02, 2019, 05:10:28 am

Title: my project can not find the shared library
Post by: noweare on September 02, 2019, 05:10:28 am
I am using ubuntu and using CB 17.12     
I have created a shared library.

I created a project to link with the shared lib.
I get the error

-------------- Build: Release in libtest1 (compiler: GNU GCC Compiler)---------------

g++ -L/home/jrm/lib/ -o bin/Release/libtest1 obj/Release/main.o  -static-libgcc -m64 -s  -ltwoints.so.0
/usr/bin/ld: cannot find -ltwoints.so.0
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

i have placed the name of the library in Project->Linker settings-> Link libraries  under Release target
I have also set the path to the libray in Search directories->linker  and Search directories->Compiler

For some reason the linker is not finding the library which is in /home/jrm/lib directory.
I also put the library in the project directory but the ide is having trouble finding it.

Thanks
Joe
Title: Re: my project can not find the shared library
Post by: noweare on September 02, 2019, 07:02:19 pm
Found the problem and was not related to code blocks. I am new to linux and wanted to 1) create a shared library  2) create a C project that used the just created shared library. 

The naming conventions between what you feed the linker and what the linker looks for and what the file name is actually is what was confounding me. When I got that figured out the project compiled. Ran the project got yet another lib not found error. Moved the library to a path where my system could find the library (symbolic link and real library). Then it worked.

Whew, lots of reading. Thank goodness for stack exchange.
Title: Re: my project can not find the shared library
Post by: BlueHazzard on September 03, 2019, 09:32:41 pm
Quote
Whew, lots of reading. Thank goodness for stack exchange.

+1  ;D

Quote
Moved the library to a path where my system could find the library (symbolic link and real library).
i personally would use ld_library_path environment variable...