Automatic loading of needed shared libraries

General questions regarding the usage of CodeLite
User avatar
eranif
CodeLite Plugin
Posts: 6375
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 »

Well, it appears to be a bug in xterm:

https://bugs.launchpad.net/ubuntu/+sour ... +bug/76618

Apparently this is also a FAQ for xterm:
http://invisible-island.net/xterm/xterm ... no_libpath

I found many reports on this issue on the web

As a workaround:
Define an external tool to launch it for you:
- from the menu: Plugins -> External Tools -> Configure External tools...
- Click 'New...'
- select an un-used ID
- You can use any available macros (click on 'Help...' button at the bottom of the dialog to get a list of them)
- give it a name 'launch wxSFDemo'
- Select the exe to run, arguments working directory etc.
- Optional: set icon etc.

Click OK, and you will have a new button in the toolbar which runs the command (base on the ID you gave it, you may assign new Keyboard shortcut for it) from 'settings -> keyboard shortcuts...' search for Plugins:: External Tools and search for your selected ID

HTH,
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 »

Hi Eran,
thanx very much for your time! I did some investigations and I've found that Code::Blocks IDE uses similar approach like CL. It uses small script called 'cb_console_runner' called by xterm which runs given application, correctly sets(!) LD_LIBRARY_PATH a and wait for pressed key at the application's end. Full command line produced by C::B is like this:

Code: Select all

$ xterm -title 'Title' -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./appexecutable
Unfortunatelly, 'cb_console_runner' is binary executable so I cannot see inside its code, but C::B is opensource project as well as the CL, so you can download the source codes and take a look into it more deeply... ;)

Regards
marfi
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've found the solution!!! :D I checked the 'cb_console_runner' source and realized that it is a really simple thing. It constructs a command line consisting of appname and definition of LD_LIBRARY_PATH variable and executes it by standard C 'system()' function. So I've written small script called 'run.sh' which can pass a content of LD_LIBRARY_PATH into xterm:

Code: Select all

#!/bin/sh
export LD_LIBRARY_PATH=.:$2
$1
echo 'Press ENTER...'
read key
Only thing the CL must to do now is to run an application by this command line:

Code: Select all

$ xterm -T 'Title' -e '/bin/sh /usr/local/run.sh ./AppPathAndName '`echo $LD_LIBRARY_PATH`
or

Code: Select all

$ xterm -T 'Title' -e /bin/sh /usr/local/run.sh ./AppPathAndName $LD_LIBRARY_PATH
Can I modify current command line myself from some CL's script/setting dialog or is it hardcoded? Another suggestion for CL is that a content for exported LD_LIBRARY_PATH can be constructed by the CL itself; for example from paths added to the linker settings and from path defined in Environment variables setting dialog (maybe the app path and LD_LIBRARY_PATH content should be enclosed by quotes).
User avatar
eranif
CodeLite Plugin
Posts: 6375
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 »

But what if the applications expects command line arguments?

Btw: Your 'run.sh' is actually CL's /usr/local/bin/le_exec.sh

Eran
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
Posts: 6375
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 »

I fixed this in SVN trunk.

The solution:
- I fixed le_exec.sh script to search for entries in the command line which has the form of name=value
- CodeLite genertes the following command line: xterm -title '<some title>' -e /bin/sh -f /usr/local/bin/le_exec.sh LD_LIBRARY_PATH=<some path> <command to run> [optional arguments...]

LD_LIBRARY_PATH is passed only when it is defined in the 'environment variable...' dialog.

- Currently only LD_LIBRARY_PATH is supported

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 »

It works great now! Thanx a lot!

marfi
Post Reply