LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2010, 07:09 AM   #1
ErEn
Member
 
Registered: Jan 2006
Location: Ankara - Turkey
Distribution: Arch Linux
Posts: 39

Rep: Reputation: 15
Question How to set RPATH in CMake?


Hey all,

This is probably an easy question but somehow I couldn't manage it to work..
I was testing the C++ WT library and I have a CMakeLists.txt file as below:
Code:
ADD_EXECUTABLE(heloooo.wt
hello.C
)

SET(CMAKE_SKIP_BUILD_RPATH FALSE)

SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 

SET(CMAKE_INSTALL_RPATH "/usr/local/lib")

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# for built-in httpd deployment:
TARGET_LINK_LIBRARIES(heloooo.wt
   wthttp wt
)

INCLUDE_DIRECTORIES(/usr/local/include)
So I can build the file but always get the following when I try to run:
Code:
./heloooo.wt: error while loading shared libraries: libwthttp.so.22: cannot open shared object file: No such file or directory
What am i doing wrong, I don't want to use the LD_LIBRARY_PATH, but to get the executable find the library with rpath when run?
 
Old 06-02-2010, 07:27 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Silly question I guess but you do have that library on your system?
 
Old 06-02-2010, 07:35 AM   #3
ErEn
Member
 
Registered: Jan 2006
Location: Ankara - Turkey
Distribution: Arch Linux
Posts: 39

Original Poster
Rep: Reputation: 15
Yep, I have already installed it and it actually works if i give the LD_LIBRARY_PATH like this:
Code:
LD_LIBRARY_PATH=/usr/local/lib ./heloooo.wt --docroot . --http-address 0.0.0.0 --http-port 8080
But my concern is that I don't want to use LD_LIBRARY_PATH?
 
Old 06-02-2010, 08:33 AM   #4
ErEn
Member
 
Registered: Jan 2006
Location: Ankara - Turkey
Distribution: Arch Linux
Posts: 39

Original Poster
Rep: Reputation: 15
OK I found a solution to this writing my own Makefile without CMake appending this option to g++ link options:
Code:
-Wl,-rpath,/usr/local/lib
But still it would be nice to learn doing CMake way of this?
 
Old 06-02-2010, 01:20 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
?? /usr/local/lib ??
is your system using the "local" as a mount point to the / on the computer you are sitting in front of ??? on a network install?


if not then DO NOT USE /usr/local !!!!!
 
Old 06-07-2010, 06:19 PM   #6
ErEn
Member
 
Registered: Jan 2006
Location: Ankara - Turkey
Distribution: Arch Linux
Posts: 39

Original Poster
Rep: Reputation: 15
Well it is not a mount point, i don't use it over network.. I just use /usr/local/ for custom installs, i think it is easier to sort out the others this way, maybe i am wrong though..
 
Old 06-07-2010, 08:15 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
depending on how "custom " the installs you might want that in your system path .
A lot of distros do not include
/usr/local/bin in the PATH
/usr/local/lib as one of the LD_LIBRARY_PATH
/usr/local/lib/pkgconfig as one of the PKG_CONFIG_PATH

you will need to set those ( depending on the distro)
this is done in gnome" .bash_profile " or /etc/profile or in one of the /etc/profil.d/ ???
 
Old 06-08-2010, 12:02 PM   #8
ErEn
Member
 
Registered: Jan 2006
Location: Ankara - Turkey
Distribution: Arch Linux
Posts: 39

Original Poster
Rep: Reputation: 15
Hmm ok.. Thank you, I will that in mind that's why I wanted to put the library path in the executable this way
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
try using -rpath or -rpath-link knobby67 Programming 5 11-12-2015 02:04 PM
cmake: Using find_package(Boost) when FindBoost.cmake is not in the default location damien_d Programming 3 10-27-2010 03:40 PM
Java Rpath ? maas187 Linux - Software 2 09-27-2009 05:20 AM
"qmake not found!" -- Qt-4.3.4 is installed, so what must I set to point cmake to it? analgesic Slackware 10 03-12-2008 09:02 PM
rPath remaster phantom_cyph Linux - General 3 05-19-2007 08:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration