Bug 340585 - Variable that holds config-output directory is not available
Summary: Variable that holds config-output directory is not available
Status: ASSIGNED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-03-21 12:53 EDT by Jonas Jonsson CLA
Modified: 2020-09-04 15:17 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Jonsson CLA 2011-03-21 12:53:23 EDT
Build Identifier: 20110218-0911

As shown at EclipseCon by Andrew, when you want to run the executable that has been linked with a shared library, the exe will not find the shared lib since it is not in the LD_LIBRARY_PATH.  The chosen output-directory should be available as a variable.

Better solution than automagically adding it: fix the ld-command so that it resolves the path when linking [by adding the run-path option in the link command].


Reproducible: Always
Comment 1 Jonas Jonsson CLA 2011-03-21 13:28:42 EDT
And the variable actually exists as ${ConfigName}, but it isn't available for the run-configuration.  Perhaps it should be that.  

But as I wrote initially, the best thing would be that the path to the shared lib should be added to the linker with -Wl,--rpath -Wl,${workspace_loc:/${ReferencedProject}/${ConfigName}
Comment 2 James Blackburn CLA 2011-03-22 06:21:34 EDT
Patches gratefully accepted.
Comment 3 James Blackburn CLA 2011-03-22 06:29:44 EDT
TBH I think it's a bad idea to add the rpath to the binary as it's asking for problems down the line.

In the example given, the rpath is hard-coded to point into the user's workspace. So while the binary might appear to magically work for that user at that instant in time, as soon as the binary is moved to another box, or the workspace is moved, the exe stops working.

I think a better bet would be to set the LD_LIBRARY_PATH appropriately and get the launch to use that.  That way the binary works nicely within Eclipse - even if the workspace is moved - but as soon as the user runs the binary outside of eclipse it's clear what dependencies the binary requires.