Page 1 of 1

Run Program won't find my local shared libraries...

Posted: Tue Aug 16, 2016 7:53 pm
by jiapei100
Hi,


My Error message from terminal:

Code: Select all

./mytest: error while loading shared libraries: libsmtest.so: cannot open shared object file: No such file or directory
Press ENTER to continue...
And what's shown in the Output View of CodeLite 9.1.7

Code: Select all

Current working directory: .../bin
Running program: /usr/bin/codelite_xterm './mytest ' '/bin/sh -f /usr/bin/codelite_exec LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/usr/lib32 [b]./mytest[/b]'
Program exited with return code: 0
However, I did add a relative path ../../lib into

Code: Select all

Project->Settings->Libraries Search Path
. It looks from the above that only the folder under current project is added to library search path when run the program. I wonder
  • Why CodeLite does NOT automatically/defaultly add my Libraries Search Path into the program search path during link/build when I try to run the program ?
  • How to add my own Libraries Search Path from within CodeLite IDE?

Cheers
Pei

Re: Run Program won't find my local shared libraries...

Posted: Tue Aug 16, 2016 9:07 pm
by eranif
Adding your library path in the project path does not affect the runtime linker search path.
You should either add the location of your library paths to the LD_LIBRARY_PATH or build your program with proper RPATH (the recommended way, if you ask me)

Eran

Re: Run Program won't find my local shared libraries...

Posted: Wed Aug 17, 2016 2:56 am
by jiapei100
Yup, Eran:

I understand that... I can definitely reset LD_LIBRARY_PATH by command line "export"
However, Where is the exactly place for me to set LD_LIBRARY_PATH from within CodeLite IDE?
Also, where is the exactly place for me to set RPATH from within CodeLite IDE??


I modified my Link Options to

Code: Select all

-rpath-link=../../lib;$(shell wx-config   --libs --unicode=yes)
, the following is what I obtained:
unrecognized command line option '-rpath-link=../../lib'
I actually tried both
-rpath-link
and
-rpath
already, NEITHER succeeded.


Thank you
Pei

Re: Run Program won't find my local shared libraries...

Posted: Wed Aug 17, 2016 4:31 am
by jiapei100
What is more:

I believe there is an easier way for the users to deal with automatically add user's Libraries Search Path into LD_LIBRARY_PATH or RPATH temporarily.
For instance, QtCreator, it can deal with such cases. Users do NOT need to add some particular settings, but ONLY specify LIBS += -Lfolder , then, libraries under folder can be called during RUN.

So, I just wonder, if CodeLite will bring this convenience in the future?


Cheers
Pei

Re: Run Program won't find my local shared libraries...

Posted: Wed Aug 17, 2016 10:08 am
by eranif
Why are you adding relative path to the rpath? I am pretty sure that this is not the standard way of doing things.
You should install your application properly, for example:
the shared libraries should go to /usr/local/lib/myapp and the binaries should go to /usr/local/bin
When building your application you should path to the linker:

Code: Select all

-Wrpath,/usr/local/lib/myapp
Changing CodeLite to hack your environment variables, is not the way to go... its just a hack to solve your problem
Eran