User forums > General (but related to Code::Blocks)

What is done exactly by Build -> Run ?

(1/2) > >>

Kalith:
Hi,

The question is in the title : on linux, what is the exact command line that C::B executes when I press Ctrl+F10 (or Build -> Run) ?
I guess that, like windows, it has to do with the "execution working dir", which I've set as the directory of the compiled executable.

My problem is, I use some .so that I've compiled myself and that are not present in the standard directories (/usr/lib, etc). Like in Windows, I've put them in the same directory as my executable.
When I run my program through C::B, everything works fine, but if I run it via the file manager, nothing shows up. If I run it manually using the console, it says it can't find any of the custom .so I'm using.

Am I doing something wrong ?

oBFusCATed:
C::B sets LD_LIBRARY_PATH for you.
In the console you should do export LD_LIBRARY_PATH="`pwd`:$LD_LIBRARY_PATH".
On unix (linux at least) the current directory is not in the library search paths, this is made for security.

Kalith:
Thank you !

I've searched for LD_LIBRARY_PATH, and found a supposedly better method : add "-Wl,-rpath,." to the linker options, and create a bash script in the program directory (assuming "prog" is the name of the program you want to run) :

--- Code: ---#!/bin/bash
cd `dirname $0`
./prog
--- End code ---

The bash script is only necessary if you run "prog" outside of its own directory. Else, the linker option is sufficient.

oBFusCATed:
Wrong, the best way is to support autotools or something similar and then install you app in the proper location for the OS.

If you should have to use a script, it is easier to export LD_LIBRARY_PATH in the script. (this is what cb is doing (see run.sh in svn))


p.s. (Installing in the proper location can be done without using autotools too)

Kalith:
Yes, but installing to the proper location is not always possible.
For example, I use my own version of some shared libraries. I could put them in a standard directory such as /usr/lib, but then all programs would use my own versions instead of the official ones, or my versions could be replaced by the original ones should I decide to (re-)install the official package.

About LD_LIBRARY_PATH, I found this webpage : [click], among others.

Navigation

[0] Message Index

[#] Next page

Go to full version