Automatic loading of needed shared libraries

General questions regarding the usage of CodeLite
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Automatic loading of needed shared libraries

Post by marfi »

Hi, I have two questions:

1) Is possible to make CL to load needed shared libraries (DLL, so,...) at a startup of application which links with them without need to have these shared libraries correctly installed in the system?

2) Is possible to defined project dependencies across a workspace? For example, can CL automatically rebuild also project linked with another project (static library) opened in the CL?

Btw, CL is realy great IDE! Keep coding... ;)
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Automatic loading of needed shared libraries

Post by eranif »

marfi wrote:1) Is possible to make CL to load needed shared libraries (DLL, so,...) at a startup of application which links with them without need to have these shared libraries correctly installed in the system?
I am not sure what do you mean here, but have you tried using 'dlopen' or wxDynamicLIbrary?
marfi wrote:2) Is possible to defined project dependencies across a workspace? For example, can CL automatically rebuild also project linked with another project (static library) opened in the CL?
Have you tried the project context menu, 'settings -> build order...' ?
marfi wrote:Btw, CL is realy great IDE! Keep coding...
Still am :)
Eran
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Automatic loading of needed shared libraries

Post by marfi »

In my previous post I meant this behaviour:

I have a project which uses (links with) my custom shared library which is not installed in the system (it means that it is not located in standard system path). If I run my app then I get error message telling me that the shared library couldn't be found (that is obvious - this error message disappears after correct installation of the shared library and everything works fine). But, If I do the same thing in Code::Blocks IDE (maybe also in VS), then the IDE loads the requested library for me without need of its installation. Is this behaviour supported by CL as well? In my opinion this approach is very useful for developping/debugging of shared libraries - I'm not forced to install them to the system after every code change...
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Automatic loading of needed shared libraries

Post by eranif »

marfi wrote:In my previous post I meant this behaviour:

I have a project which uses (links with) my custom shared library which is not installed in the system (it means that it is not located in standard system path). If I run my app then I get error message telling me that the shared library couldn't be found (that is obvious - this error message disappears after correct installation of the shared library and everything works fine). But, If I do the same thing in Code::Blocks IDE (maybe also in VS), then the IDE loads the requested library for me without need of its installation. Is this behaviour supported by CL as well? In my opinion this approach is very useful for developping/debugging of shared libraries - I'm not forced to install them to the system after every code change...
Yes, CodeLite supports that.
- go to 'settings -> environment variables'
- define new environment variable named: PATH
as value set: $(PATH);/path/to/your/shared/library

(replace /path/to/your/shared/library with the actual path ofc)
Note: the $(PATH); is very important!

Now CodeLite will be able to locate your shared libraries without the need for them to be installed.

Eran
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Automatic loading of needed shared libraries

Post by marfi »

eranif wrote:
marfi wrote:In my previous post I meant this behaviour:

I have a project which uses (links with) my custom shared library which is not installed in the system (it means that it is not located in standard system path). If I run my app then I get error message telling me that the shared library couldn't be found (that is obvious - this error message disappears after correct installation of the shared library and everything works fine). But, If I do the same thing in Code::Blocks IDE (maybe also in VS), then the IDE loads the requested library for me without need of its installation. Is this behaviour supported by CL as well? In my opinion this approach is very useful for developping/debugging of shared libraries - I'm not forced to install them to the system after every code change...
Yes, CodeLite supports that.
- go to 'settings -> environment variables'
- define new environment variable named: PATH
as value set: $(PATH);/path/to/your/shared/library

(replace /path/to/your/shared/library with the actual path ofc)
Note: the $(PATH); is very important!

Now CodeLite will be able to locate your shared libraries without the need for them to be installed.

Eran
Hi, thank you for your fast reply, unfortunately it doesn't work... :( I set the PATH environment variable as you described (I used the same path to the shared library like in the linker setting - without the name, of course), compilation and linking works fine, but if I want to run the app it still cannot locate the shared library. Do I omit something important in the project/IDE settings? I attached the project file and the environment configuration file bellow.
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Automatic loading of needed shared libraries

Post by eranif »

You forgot to mention your OS (which by the path you added, I figured it is LInux)

Chnage the environment variable to:
$(PATH):/home/michal/Src/Projekty/wxSF/lib/gcc_dll

Notice that I used here ':' as separator unlike earlier where you set ';' (which is relevant for Windows)

Eran
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Automatic loading of needed shared libraries

Post by eranif »

Thinking of it now... it wont work.

PATH is the proper variable to set under windows, on Linux:
Do the same as you did with PATH but for LD_LIBRARY_PATH
And of course, use colons as the separator ':'

Eran
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Automatic loading of needed shared libraries

Post by marfi »

eranif wrote:You forgot to mention your OS (which by the path you added, I figured it is LInux)

Chnage the environment variable to:
$(PATH):/home/michal/Src/Projekty/wxSF/lib/gcc_dll

Notice that I used here ':' as separator unlike earlier where you set ';' (which is relevant for Windows)

Eran
Oops, sorry for that: I use Ubuntu 8.10, wxWidgets 2.8.9. I really don't want to waste your time, maybe I'm awkward, but it still doesn't work... I tried to modify the PATH var in some ways and in some cases the CL wasn't able even to compile (so it means it really processes the ENV vars ;) ), but the app cannot be ran.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Automatic loading of needed shared libraries

Post by eranif »

You should read my later post about you needing to modify LD_LIBRARY_PATH instead of PATH
Eran
Make sure you have read the HOW TO POST thread
marfi
CodeLite Expert
Posts: 159
Joined: Mon Nov 03, 2008 9:17 pm
Contact:

Re: Automatic loading of needed shared libraries

Post by marfi »

I was writing my last post simultaneously to you were doing the same so I missed it. Unfortunately it still doesn't work but maybe I found out reason why:

If I do the recommended steps from the command line in the following way everything goes well:

Code: Select all

$ export LD_LIBRARY_PATH=/home/michal/Src/Projekty/wxSF/lib/gcc_dll/
$ ./wxSFDemo
<- OK

But, if I try run my app via xterm like the CL does, it doesn't work. It seems like the xterm doesn't use LD_LIBRARY_PATH variable.

Code: Select all

$ export LD_LIBRARY_PATH=/home/michal/Src/Projekty/wxSF/lib/gcc_dll/
$ xterm -title './wxSFDemo ' -e /bin/sh -f /usr/local/bin/le_exec.sh ./wxSFDemo
<- ERROR
Post Reply