Message: Need help linking a shared library when compiling simulation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Need help linking a shared library when compiling simulation 

Forum: Installation and Configuration
Date: 02 Mar, 2012
From: Johnathan Sparger <Johnathan Sparger>

--f46d0447f07663bf4804ba3e747f
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I am trying to link a shared library which contains my dictionaries for
ROOT. This library is called RootDictionaryLib.so. I have modified my
makefile to include these lines:


PPFLAGS += -I/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict
EXTRALIBS +=
/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDictionaryLib.so
EXTRA_LINK_DEPENDENCIES :=
/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDictionaryLib.so


when I type make, everything compiles fine. However, when I try to run the
program, I get this error:

dyld: Library not loaded: RootDictionaryLib.so
  Referenced from:
/Users/jsparger/spring2012/nbd/nbd/branches/doi/./bin/Darwin-g++/neutronBlockDetector
  Reason: image not found
Trace/BPT trap


I have tried running the executable in a script with LD_LIBRARY_PATH set
to /Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/, but it
doesn't seem to help at all.

Could someone explain how I can link this ROOT library? I noticed the
examples here:

http://geant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/html/Appendix/makeFile.html

only used static libraries. Is there a different process for a shared
library? I'll copy my makefile below.

Thank you
--John





My makefile:
#######################################################

name := neutronBlockDetector
G4TARGET := $(name)
G4EXLIB := true
G4WORKDIR := ./

# to add an external library (root dictionary library)
CPPFLAGS += -I/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict
EXTRALIBS +=
/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDictionaryLib.dylib
EXTRA_LINK_DEPENDENCIES :=
/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDictionaryLib.dylib


ifndef G4INSTALL
  G4INSTALL = ../../..
endif

.PHONY: all
all: lib bin

include $(G4INSTALL)/config/binmake.gmk


ifndef G4UI_USE_ROOT
    ROOTCPPFLAGS   = $(shell root-config --cflags)
    CPPFLAGS      += -DG4ANALYSIS_USE_ROOT $(ROOTCPPFLAGS)
    CPPFLAGS      +=-Wno-deprecated
    ROOTLIBS       = $(shell root-config --nonew --glibs)
    ROOTLIBS      := $(filter-out -lNew,$(ROOTLIBS))
    ROOTLIBS      += -lMinuit -lHtml
    LDLIBS        += $(ROOTLIBS)
  endif

--f46d0447f07663bf4804ba3e747f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,<div><br></div><div>I am trying to link a shared library which contains =
my dictionaries for ROOT. This library is called=A0RootDictionaryLib.so. I =
have modified my makefile to include these lines:</div><div><br></div><div>
<br></div><div><div>PPFLAGS +=3D -I/Users/jsparger/spring2012/nbd/nbd/branc=
hes/doi/root_dict</div><div>EXTRALIBS +=3D /Users/jsparger/spring2012/nbd/n=
bd/branches/doi/root_dict/RootDictionaryLib.so</div><div>EXTRA_LINK_DEPENDE=
NCIES :=3D /Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDi=
ctionaryLib.so</div>
</div><div><br></div><div><br></div><div>when I type make, everything compi=
les fine. However, when I try to run the program, I get this error:</div><d=
iv><br></div><div><div>dyld: Library not loaded: RootDictionaryLib.so</div>
<div>=A0 Referenced from: /Users/jsparger/spring2012/nbd/nbd/branches/doi/.=
/bin/Darwin-g++/neutronBlockDetector</div><div>=A0 Reason: image not found<=
/div><div>Trace/BPT trap</div></div><div><br></div><div><br></div><div>I ha=
ve tried running the executable in a script with LD_LIBRARY_PATH set to=A0/=
Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/, but it doesn&#39=
;t seem to help at all.</div>
<div><br></div><div>Could someone explain how I can link this ROOT library?=
 I noticed the examples here:</div><div><br></div><div><a href=3D"http://ge=
ant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDevelope=
r/html/Appendix/makeFile.html">http://geant4.web.cern.ch/geant4/G4UsersDocu=
ments/UsersGuides/ForApplicationDeveloper/html/Appendix/makeFile.html</a></=
div>
<div><br></div><div>only used static libraries. Is there a different proces=
s for a shared library? I&#39;ll copy my makefile below.</div><div><br></di=
v><div>Thank you</div><div>--John</div><div><br></div><div><br></div><div>
<br></div><div><br></div><div><br></div><div>My makefile:</div><div>#######=
################################################</div><div><br></div><div><=
div>name :=3D neutronBlockDetector</div><div>G4TARGET :=3D $(name)</div><di=
v>
G4EXLIB :=3D true</div><div>G4WORKDIR :=3D ./</div><div><br></div><div># to=
 add an external library (root dictionary library)</div><div>CPPFLAGS +=3D =
-I/Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict</div><div>EXTRA=
LIBS +=3D /Users/jsparger/spring2012/nbd/nbd/branches/doi/root_dict/RootDic=
tionaryLib.dylib</div>
<div>EXTRA_LINK_DEPENDENCIES :=3D /Users/jsparger/spring2012/nbd/nbd/branch=
es/doi/root_dict/RootDictionaryLib.dylib</div><div><br></div><div><br></div=
><div>ifndef G4INSTALL</div><div>=A0 G4INSTALL =3D ../../..</div><div>endif=
</div>
<div><br></div><div>.PHONY: all</div><div>all: lib bin</div><div><br></div>=
<div>include $(G4INSTALL)/config/binmake.gmk</div></div><div><br></div><div=
><br></div><div><div>ifndef G4UI_USE_ROOT</div><div>=A0 =A0 ROOTCPPFLAGS =
=A0 =3D $(shell root-config --cflags)=A0</div>
<div>=A0 =A0 CPPFLAGS =A0 =A0 =A0+=3D -DG4ANALYSIS_USE_ROOT $(ROOTCPPFLAGS)=
</div><div>=A0 =A0 CPPFLAGS =A0 =A0 =A0+=3D-Wno-deprecated</div><div>=A0 =
=A0 ROOTLIBS =A0 =A0 =A0 =3D $(shell root-config --nonew --glibs)</div><div=
>=A0 =A0 ROOTLIBS =A0 =A0 =A0:=3D $(filter-out -lNew,$(ROOTLIBS))</div>
<div>=A0 =A0 ROOTLIBS =A0 =A0 =A0+=3D -lMinuit -lHtml</div><div>=A0 =A0 LDL=
IBS =A0 =A0 =A0 =A0+=3D $(ROOTLIBS)</div><div>=A0 endif</div></div>

--f46d0447f07663bf4804ba3e747f--

 Add Message Add Message
to: "Need help linking a shared library when compiling simulation"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]