News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

LD_LIBRARY_PATH Not Used

Started by Game_Ender, January 05, 2006, 06:11:01 PM

Previous topic - Next topic

Game_Ender

I am using rev 1658 and I am trying to run an Application from within Code::Blocks that links against libraries in LD_LIBRARY_PATH.  The libraries are in /usr/local/lib and I have edited my .bashrc to include this, so I can run the application manully from the command line fine.  I am compiling with a custom make file and that works fine too.  Yet when ever I try to run the app either as a GUI Application or a Console Application it can't find the libraries.  This happens even if I start Code::Blocks from the same terminal that I am able to run the app manually from.

tiwag

#1
look there, several possibilities how to solve this ...
http://forums.next.codeblocks.org/index.php?topic=1779.msg13287#msg13287


run from terminal
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH  ./executable_name


btw - i just now built CB under ubuntu linux and if using the CodeBlocks-unix.cbp project file
i can start my debuggee fine.

maybe with Gentoo it does work slightly modified - can you have a look in your gentoo docs please ?

Game_Ender

Sorry, I forgot to mention I am using Ubuntu 5.10 Breezy Badger.  I can run the program fine from the terminal without explicitly stating the LD_LIBRARY_PATH.  When I put the LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib in front of the executable name in Project->Target Options dialog Code::Blocks just sits there forever running at 95%-100% CPU usage for way longer than it takes the program to start.  I have also seen that thread you mentioned and I am not trying to run Code::Blocks, only my custom application.

tiwag

i use also ubuntu 5.10 breezy - don't know why it works for me but not for you ?

Game_Ender

I have a hack/workaround and I still trying to figure out why it doesn't work:

I renamed console_runner console_runner_prog and created this script called console_runner:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib /home/jlisee/apps/codeblocks-svn/bin/console_runner_prog $*

So codeblocks invokes the script which invokes the real console runner with the proper LD_LIBRARY_PATH and all the arguments.

tiwag


tiwag

i remember, that i had a similar issue in the past and i could solve it, by a systemwide terminal setting.

there is any option , where you can select, if the standard terminal profile opens the terminal as login terminal or not.
if you set this to login-type, then all the pathes and settings are inherited otherwise not
(i was fighting with some pathes which i've had in my login terminals, but not in terminals which were openend from gnome gui)
since that time i always set this option to login-type by default ;-)

tiwag

maybe i should also mention that i use the gnome-terminal to run my console apps
(standard in C::B is xterm IIRC)

Urxae

#8
Quote from: Game_Ender on January 05, 2006, 06:11:01 PM
I am using rev 1658 and I am trying to run an Application from within Code::Blocks that links against libraries in LD_LIBRARY_PATH.  The libraries are in /usr/local/lib and I have edited my .bashrc to include this, so I can run the application manully from the command line fine.  I am compiling with a custom make file and that works fine too.  Yet when ever I try to run the app either as a GUI Application or a Console Application it can't find the libraries.  This happens even if I start Code::Blocks from the same terminal that I am able to run the app manually from.

What is the exact line in your .bashrc? Is it LD_LIBRARY_PATH=/usr/local/lib or export LD_LIBRARY_PATH=/usr/local/lib?

(I know you fixed it by replacing consolerunner, but that's hardly the cleanest solution)

Game_Ender

The exact line is this:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

I also just tested an xterm, started from both from a Gnome terminal and the application menu, both echoed the proper LD_LIBRARY_PATH.  I have no idea what is going on.

Urxae

Is there any way you could check what the LD_LIBRARY_PATH is inside a program ran by C::B?
Maybe compile & run something this through it:
#include <stdlib.h>
int main() { system("/bin/$sh"); }

(But remove the $ that I had to put in to get this F-ing forum to let me post! :evil: :evil: :evil:)
and enter echo $LD_LIBRARY_PATH at the prompt?


Probably a security "feature" to prevent injection attacks or whatever, but VERY annoying. If only it would TELL me what was wrong with it instead of
Quote from: evil forum server(title: "406 Not Acceptable")
Not Acceptable

An appropriate representation of the requested resource /index.php could not be found on this server.


Apache/1.3.34 Server at forums.next.codeblocks.org Port 80