Author Topic: Does cb_console_runner clear LD_LIBRARY_PATH????  (Read 4818 times)

Offline dpu

  • Single posting newcomer
  • *
  • Posts: 3
Does cb_console_runner clear LD_LIBRARY_PATH????
« on: October 21, 2008, 11:08:55 pm »
If I run a program from within Code::Blocks:
Code
Executing: xterm -T OsgVertexProgramTest -e /usr/bin/cb_console_runner /home/dunrau/src/dev/OsgVertexProgramTest/bin/Debug/OsgVertexProgramTest  (in /home/dunrau/src/dev/OsgVertexProgramTest/.)
LD_LIBRARY_PATH is not set, although other environment variables I define are.  Why is this happening?  More details below:

I'm running Code::Blocks 8.02 on ubuntu 8.10.  I have a console app that needs some directories in LD_LIBRARY_PATH so that the required libraries can be found at run time.  When I run the program from code::blocks, the libraries cannot be found.  When I debug from within Code::Blocks, or run from a shell outside of Code::Blocks, the program runs fine.  This is irrespective of whether I define LD_LIBRARY_PATH in my .bashrc, in Code::Blocks environment variables, or add the directories to the project->Build Options->Search directories->Linker area.

With this test program:
Code
#include <iostream>
#include <cstdlib>

using namespace std;

void printEnv(const char* pName)
{
    char* pValue = getenv(pName);
    if (pValue)
    {
        cout << pName << "=" << pValue << endl;
    }
    else
    {
        cout << pName << " not set" << endl;
    }
}


int main()
{
    char input[256];
    cout << "Hello world!" << endl;

    printEnv("PATH");
    printEnv("DU_TEST");
    printEnv("LD_LIBRARY_PATH");
    printEnv("OSG_FILE_PATH");
    cin >> input;
    return 0;
}
I can see that LD_LIBRARY_PATH values that I set are fine every way I run the program except if I run it from the Code::Blocks run icon.  When I run the program this way, LD_LIBRARY_PATH is not set.

Any ideas why this is happening????  It seems  this topic is the same problem: http://forums.codeblocks.org/index.php/topic,9197.0.html, but no solutions are listed....

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Does cb_console_runner clear LD_LIBRARY_PATH????
« Reply #1 on: October 22, 2008, 02:58:48 pm »
Any ideas why this is happening????

It's written in my post of the other thread you refer to:
http://forums.codeblocks.org/index.php/topic,9197.0.html

I'm afraid you need to modify the C::B sources slightly... Look for "LD_LIBRARY_PATH" in compilergcc.cpp of the compiler plugin. I can't tell more as I am not a Linux guy. Probably some other devs can provide additional information.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dpu

  • Single posting newcomer
  • *
  • Posts: 3
Re: Does cb_console_runner clear LD_LIBRARY_PATH????
« Reply #2 on: October 22, 2008, 03:22:46 pm »
Thanks - looks like that is the code that is controlling this.  So, this is a bug then.  I looked through compiler.gcc and I can't see an obvious problem.  I can't find a bug report on this.  Should I raise one???
« Last Edit: October 22, 2008, 03:27:44 pm by dpu »