Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How do I use relative paths with -rpath???(Need to set path to so file)
How do I use relative paths with -rpath??? [message #1718787] Wed, 30 December 2015 09:51 Go to next message
Anders Garp is currently offline Anders GarpFriend
Messages: 3
Registered: December 2015
Junior Member
Hi,

I want to use a shared library in my application. To do so I like to specify the relative path to the so file using the -rpath flag. It works for absolute paths but not relative paths. I've tried the $ORIGIN (which have to write like $$ORIGIN) but it doesn't work. Any ideas?

Best,
Anders
Re: How do I use relative paths with -rpath??? [message #1718826 is a reply to message #1718787] Wed, 30 December 2015 19:40 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
A little more context wouldn't hurt. How are you trying to use -rpath?
Re: How do I use relative paths with -rpath??? [message #1718981 is a reply to message #1718826] Mon, 04 January 2016 09:13 Go to previous messageGo to next message
Anders Garp is currently offline Anders GarpFriend
Messages: 3
Registered: December 2015
Junior Member
I'm using eclipse CDT and have a shared library that I like to call functions in. I need to tell where my main application is looking for this .so file and I can do that by specifying a folder where my library is using the -rpath. I like my path to be relative to where my main application is. Ideally they should be in the same folder. But I cannot specify relative paths, it simply does not work. I've seen examples of how to use relative paths on the internet but of some reasons it doesn't work.

Re: How do I use relative paths with -rpath??? [message #1719046 is a reply to message #1718981] Mon, 04 January 2016 17:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Yes, you are using CDT with Eclipse. Got that.
By context, I meant how and where you are using -rpath.
What do you mean by "simply does not work"?
Your posts boil down to: I tried to use -rpath. It didn't work. Why?
Are we supposed to figure out what you've done?
Re: How do I use relative paths with -rpath??? [message #1719145 is a reply to message #1719046] Tue, 05 January 2016 15:43 Go to previous messageGo to next message
Anders Garp is currently offline Anders GarpFriend
Messages: 3
Registered: December 2015
Junior Member
Dear David,

What I've found on forums is that I can use the word $ORIGIN to create a relative path to were the executable is. So for instance if my .so file is in a subfolder relative to the executable and that folder is called lib. Then I should be able to use:

-rpath $ORIGIN/lib

But for me I simple get the message that the so file cannot be found if I try to run the executable after compiling with this flag.
Re: How do I use relative paths with -rpath??? [message #1719152 is a reply to message #1719145] Tue, 05 January 2016 16:12 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
This is a rather complicated subject which is out of scope for this forum.
See:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html
http://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime

If you still can't get it to work you could ask at stackoverflow.com but you won't get too far if you aren't more explicit in how you are using it (HINT: show the actual command line and text of what you are seeing).

The key here may be you are trying to compile with this option when it is actually a linker option but you seem reluctant to show exactly what you are doing and want to engage in a guessing game.

[Updated on: Wed, 06 January 2016 17:39]

Report message to a moderator

Previous Topic:Setting up embedded c
Next Topic:MinGW-w64
Goto Forum:
  


Current Time: Fri Apr 19 18:51:17 GMT 2024

Powered by FUDForum. Page generated in 0.03264 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top