Author Topic: LD_LIBRARY_PATH Not Used  (Read 10016 times)

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
LD_LIBRARY_PATH Not Used
« 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.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: LD_LIBRARY_PATH Not Used
« Reply #1 on: January 05, 2006, 06:18:48 pm »
look there, several possibilities how to solve this ...
http://forums.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 ?
« Last Edit: January 05, 2006, 06:21:50 pm by tiwag »

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: LD_LIBRARY_PATH Not Used
« Reply #2 on: January 05, 2006, 06:28:31 pm »
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.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: LD_LIBRARY_PATH Not Used
« Reply #3 on: January 05, 2006, 06:33:37 pm »
i use also ubuntu 5.10 breezy - don't know why it works for me but not for you ?

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: LD_LIBRARY_PATH Not Used
« Reply #4 on: January 05, 2006, 06:40:14 pm »
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:
Code
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.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: LD_LIBRARY_PATH Not Used
« Reply #5 on: January 05, 2006, 06:42:53 pm »
perfect done !

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: LD_LIBRARY_PATH Not Used
« Reply #6 on: January 05, 2006, 06:46:45 pm »
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 ;-)

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: LD_LIBRARY_PATH Not Used
« Reply #7 on: January 05, 2006, 06:53:56 pm »
maybe i should also mention that i use the gnome-terminal to run my console apps
(standard in C::B is xterm IIRC)

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: LD_LIBRARY_PATH Not Used
« Reply #8 on: January 05, 2006, 08:01:25 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
Code
LD_LIBRARY_PATH=/usr/local/lib
or
Code
export LD_LIBRARY_PATH=/usr/local/lib
?

(I know you fixed it by replacing consolerunner, but that's hardly the cleanest solution)
« Last Edit: January 05, 2006, 08:03:41 pm by Urxae »

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: LD_LIBRARY_PATH Not Used
« Reply #9 on: January 05, 2006, 09:46:08 pm »
The exact line is this:

Code
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.

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: LD_LIBRARY_PATH Not Used
« Reply #10 on: January 05, 2006, 11:50:54 pm »
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:
Code
#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.codeblocks.org Port 80