Author Topic: How to link .so's ?  (Read 3257 times)

Offline BruceGerdes

  • Single posting newcomer
  • *
  • Posts: 4
How to link .so's ?
« on: May 15, 2010, 12:19:01 am »
Hi, all:
It appears that when one links a main program with .so's, it stores the name of the .so defined under "Linker settings" in the executable, complete with the fully-qualified or relative path name.  When the program runs, it uses that path to find the .so's.  What I want is to make the main program look for the libraries it needs in whatever directory the main program happens to be in:  that way, I can drop the program and its libraries in any directory and it will run.  It seems as if I should be able to do this by defining the name of the .so with no path reference in "Linker settings" and put the path in "Search directories - linker", but I can't seem to make this work.  What am I doing wrong?

Bruce

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7665
    • My Best Post
Re: How to link .so's ?
« Reply #1 on: May 15, 2010, 01:59:17 am »
Wild guess, Turn on Full Compiler Logging and post the information from a re-build for an expect to read. Edit: I am not the expect needed; need real Linux user to give feedback.

See Wiki FAQ if you do not know how to do above.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: How to link .so's ?
« Reply #2 on: May 15, 2010, 01:24:01 pm »
This question is not related to C::B, but to (dynamically) linking on linux.
So this is the wrong website to ask for and your topic might get locked, because it violates our forum rules.

There are several tutorials about using dynamic libs on linux.
C::B itself uses a wrapper-script to start if it is build by itself with the project-file (it will be created by the update-script, that should be run after building from source with C::B).

Alternatively you can link your lib statically (if a static library is provided and does not blow up the executable too much).
You can keep the executable smaller by running a exe-packer (like upx) in the post-build steps.

Offline BruceGerdes

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to link .so's ?
« Reply #3 on: May 15, 2010, 04:21:29 pm »
Jens:

Yeah, I see what you mean.  Following the YoLinux tutorial, all I had to do was set up some symbolic links outside of Code::Blocks.  If you put full path names in the main program (by putting full path names in "Linker settings"), you don't need to do that, and you can develop the entire program without ever leaving Code::Blocks.  Which is what I did.

By the way, Code::Blocks is hands down the best IDE I've ever used.  Hat's off to you guys.

Bruce