Problem 2086 - G4RUNPATHOPTION should have trailing comma for Clang and g++ configurations
Summary: G4RUNPATHOPTION should have trailing comma for Clang and g++ configurations
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: config (show other problems)
Version: 10.3
Hardware: Other Linux
: P4 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2018-09-06 21:13 CEST by Michael Kelsey
Modified: 2018-09-07 11:53 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Michael Kelsey 2018-09-06 21:13:00 CEST
One of my users reported to me that he wasn't able to run our Geant4-based simulation, and he couldn't run the G4 examples either.  Building on his Mac using the GNUMakefile system, he got the following error, which I can reproduce:

$ exampleB1
dyld: Library not loaded: @rpath/libG4Tree.dylib
  Referenced from: /Users/kelsey/geant4_workdir/bin/Darwin-clang/exampleB1
  Reason: image not found
Abort

The problem arises because G4RUNPATHOPTION is not set correctly in the config/system/{Linux,Darwin}-{clang,g++}.gmk files.  In those four files, the setting is

  G4RUNPATHOPTION := -Wl,-rpath

which is later used in binmake.gmk as

  LDFLAGS += $(G4RUNPATHOPTION)$(G4TMPDIR)

The option string needs to have a trailing comma, so that the directory is included in what gets passed to LD (i.e., -Wl,-rpath,<path-to-libraries> results in "-rpath <path-to-libraries>").  

Additionally, binmake.gmk should use the G4RUNPATHOPTION construction above for both the executables own library ($(G4TMPDIR) above), and for the Geant4 main libraries; thus:

  LDFLAGS += $(G4RUNPATHOPTION)$(G4TMPDIR)
  LDFLAGS += $(G4RUNPATHOPTION)$(G4LIB)/$(G4SYSTEM)

I was able to work around the problem by (a) modifying G4RUNPATHOPTION, and (b) adding the last line above, in my own application's GNUMakefile.
Comment 1 Gabriele Cosmo 2018-09-07 11:53:31 CEST
Thanks for reporting this. The fix is now tagged config-V10-04-06 and will be included in the patch and/or release.

Please, note that the GNUMake system is deprecated since long and only used for internal development. Consider switching your software to CMake, as GNUMake may soon be removed!