This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252516 - Wrong rpath option added when link libraries added using
Summary: Wrong rpath option added when link libraries added using
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Toolchain (show other bugs)
Version: 8.0.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-21 04:10 UTC by snunez
Modified: 2016-02-19 02:33 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description snunez 2015-05-21 04:10:24 UTC
When libraries are added to the linker using "Add Project" (Properties>Build>Linker>Libraries>"Add Project"), a rpath option is added to the command line with the lib path for each library added (I verifyed this using GNU).
'rpath-link' should be used instead of 'rpath'
The rpath should be used only once in the command line with multiple path separated with commas, and since in Netbeans is used once for each project, only the first one is accepted. 
Could be verified with 'ldd libfoo.so'.
This generate a problem since all the libraries dependencies used when linking foo are searched in the path of the first one.

rpath-link can be used once for each project, and did not add a rpath to the library, since only validate at link time, that is preferable since the path used for compilation (usualy dist/...) should not be the final running path, and for setting Running Search Directories ther is another configurable option. 

At org/netbeans/modules/cnd/toolchain/resources/toolchaindefinition/GNU_linker.xml
<dynamic_library_search flags="-Wl,-rpath,"/>
should be replaced with:
<dynamic_library_search flags="-Wl,-rpath-link,"/>
Comment 1 Alexander Simon 2015-05-22 10:00:53 UTC
docs:
http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html
Comment 2 soldatov 2015-05-22 11:27:25 UTC
Possible problems:
1) doesn't work on Solaris. For example: https://mail.haskell.org/pipermail/ghc-devs/2013-January/000151.html
2) by default debug and run will fail with "./test2: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory" error
Comment 3 snunez 2015-05-22 16:38:22 UTC
1 ) I understand, this should be applied only for GNU on Linux. Maybe if using rpath or rpath-link could be configurable or taken from an environment variable if it exist.
2 ) This is because you need to set the lib path at LD_LIBRARY_PATH or ld.config. Using rpath as used right now allow you not to need define those settings, but generate a lib that reference a path that only exist on developement environment.


Ther are other problems keeping rpath:
 Among that, rpath should appear only once in a compilation line, and as it is used right now, it appears many times, once for each libary referenced as a Project.
Comment 4 snunez 2015-05-22 23:51:12 UTC
Correction for what I said: rpath CAN be used more than one in a compile line.

Note: 

All other linker library asociation ("Add Library" and "Add Library File") doesn't add any rpath link option, just add the -L and -l options.
Comment 5 snunez 2015-05-23 01:59:21 UTC
What I'd like to be able to do is to set RPATH as $ORIGIN/../lib as documented in http://man7.org/linux/man-pages/man8/ld.so.8.html
Comment 6 Alexander Simon 2016-02-17 12:39:04 UTC
fixed, change set:http://hg.netbeans.org/cnd-main/rev/da3a968ae73c
Comment 7 Quality Engineering 2016-02-18 02:34:37 UTC
Integrated into 'main-silver', will be available in build *201602180002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/da3a968ae73c
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #252516 Wrong rpath option added when link libraries added using "Add Project"
Comment 8 Quality Engineering 2016-02-19 02:33:47 UTC
Integrated into 'main-silver', will be available in build *201602190002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ea948753cfc4
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #252516 Wrong rpath option added when link libraries added using "Add Project"
- extract origin constant