Author Topic: [SELF SOLVED BUT SOLVED] Hardcode dynamic library search path  (Read 4783 times)

Offline rnodal

  • Single posting newcomer
  • *
  • Posts: 9
Hello all :D:

I'm trying to build an app using Ogre. It all goes well and it links fine. No errors, no warnings. It's great. :D
But when I run the application; it complains about not finding "libOgreMain-1.4.1.so". This is the build log:

Code
-------------- Build: Debug in project001 ---------------
g++ -Wall -g  -I../../DevLibs/Ogre/include -I../../DevLibs/OIS/include -I/usr/include  -c /home/rnodal/Projects/project001/src/game.cpp -o obj/Debug/src/game.o
g++ -Wall -g  -I../../DevLibs/Ogre/include -I../../DevLibs/OIS/include -I/usr/include  -c /home/rnodal/Projects/project001/src/inputsystem.cpp -o obj/Debug/src/inputsystem.o
g++ -Wall -g  -I../../DevLibs/Ogre/include -I../../DevLibs/OIS/include -I/usr/include  -c /home/rnodal/Projects/project001/src/main.cpp -o obj/Debug/src/main.o
g++ -L/usr/lib  -o ./project001_d obj/Debug/src/game.o obj/Debug/src/inputsystem.o obj/Debug/src/main.o    lib/libOIS.a lib/OgreMain.so
Process terminated with status 0 (0 minutes, 6 seconds)
0 errors, 0 warnings


I did not tell C::B to use libOgreMain-1.4.1.so in the first place and neither to use /usr/lib. Any place where I can check for this things? I want the application to use the libs in my ./lib folder so when I give to someone they can just run it.

Any input on this manner will be welcomed. Thanks for your time.

-r
« Last Edit: May 26, 2007, 08:02:24 pm by rnodal »

Offline rnodal

  • Single posting newcomer
  • *
  • Posts: 9
Re: Stop C::B from using /usr/lib
« Reply #1 on: May 26, 2007, 07:17:06 pm »
More information:

Here is the output of ldd:
Code
linux-gate.so.1 =>  (0xffffe000)
libOgreMain-1.4.1.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7e9f000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7e77000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7e6b000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d2a000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb7c39000)
/lib/ld-linux.so.2 (0xb7fa8000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb7c36000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb7c30000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7c2c000)

thanks again!

-r

Offline rnodal

  • Single posting newcomer
  • *
  • Posts: 9
Re: Stop C::B from using /usr/lib
« Reply #2 on: May 26, 2007, 07:59:58 pm »
Problem solved :):):):). Did I mention I love C::B :):):):).

For the record if you add "-Wl, -Rpath" where path could be something like "./libs" to your linker "other options" your program would search for the required libs under that directory and be happy. This is all under linux  8), in windows you just put the dll in the same folder as the exe. :P

Take care all


-r

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: [SELF SOLVED BUT SOLVED] Hardcode dynamic library search path
« Reply #3 on: May 26, 2007, 11:32:44 pm »
I did not tell C::B to use libOgreMain-1.4.1.so in the first place and neither to use /usr/lib. Any place where I can check for this things? I want the application to use the libs in my ./lib folder so when I give to someone they can just run it.

Any input on this manner will be welcomed. Thanks for your time.

-r

I know you have solved your problem, but you will probably find it useful to know that in linux gcc has standard include and lib directories such as /usr/include and /usr/lib (this is also true in windows, the paths are obviously different, though)

while you can solve your problems by directly specifying linker options as you have done it is even easier to use cb build options:

if you want to add additional paths for your cb project (or a specific build within a project), just goto project -> build options -> search directories and add compiler and linker paths. these will take precedence over the standard gcc paths.

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: [SELF SOLVED BUT SOLVED] Hardcode dynamic library search path
« Reply #4 on: May 27, 2007, 07:02:11 am »
No the problem here is that if you use a custom LD_LIBRARY_PATH Code::Blocks by default just completely ignores it, ,aking it very hard to actually debug your application.  I really wish I could just set environment variables that CB should set every time I run my target.  (Currently attempting a patch).