problem in dynamic library*.so

hello
I apologize if my question bothers you
I work on a code developed in C + + which worked well on mac os, this code will help create libraries *.so from *.cc and *.h I used this as flags:CXXFLAGS = -g -O2 -fPIC -Wall -ldl -D_GNU_SOURCE ,CXX := g++ and $(CXX)-shared -o $(LIBNAME) $(CLIBLIB) $(OUT_OBJS)this step is fine I got the *.so as follows. :
*****************************************
morad@linux-nzlc:~/Musique/workdir> ls library/tklibs/lib/
libAnalyticalJacobians.so libDetGeometry.so libGeomPropagators.so libPatternTestTools.so libSmearingClusterizers.so libTkLayout.so
libBaseMagneticField.so libDetLayout.so libKalmanUpdators.so libPatternTools.so libStatUtilities.so libTkNavigation.so
libBasicDet.so libDetUtilities.so libMaterialEffects.so libPropagators.so libSurfaceGeometry.so libTrackFitters.so
libBasicStripDet.so libDetVolumeGeometry.so libNumericalJacobians.so libRKPropagators.so libTkCommonDet.so libTrajectoryParametrization.so
libCommonStripDet.so libGenUtil.so libPatternPrimitives.so libSiPixelDet.so libTkFastSimHit.so libUI.so
morad@linux-nzlc:~/Musique/workdir>
*****************
then the second step I would create the executable for that I specify the-I,-L and-l in makfile I as flags:CXX = g++ and $(CXX) -O2 -g -fopenmp $(CILIBLAY) $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o -o $(MAIN_PROG).exe but after running it I get an error:
***************************************
morad@linux-nzlc:~/Musique/workdir/layout/analyze> make mainP=runAnalyze
Makefile:85: /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d: Aucun fichier ou dossier de ce type
g++ -MM -I/cern/CLHEP/2.0.4.5/include/ -I/home/morad/Musique/workdir/layout -I/home/morad/Musique/workdir/library/tklibs -I/cern/ROOT/source/root/include -I/usr/include/freetype2/freetype/ -I/usr/include/freetype2 -I/cern/Minuit2/5.28.00/include -I/usr/include/libxml2 -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include/ -I/usr/include/glibmm-2.4/ -I/usr/lib/glibmm-2.4/include/ -I/usr/include/sigc++-2.0/ -I/usr/lib/sigc++-2.0/include/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/cern/gettext/0.18.2/include/ myAnalyze.cc > /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d.$$; \
sed 's,\(myAnalyze\)\.o[ :]*,\1.o /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d : ,g' < /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d.$$ > /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d; \
rm -f /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d.$$
g++ -c -I/cern/CLHEP/2.0.4.5/include/ -I/home/morad/Musique/workdir/layout -I/home/morad/Musique/workdir/library/tklibs -I/cern/ROOT/source/root/include -I/usr/include/freetype2/freetype/ -I/usr/include/freetype2 -I/cern/Minuit2/5.28.00/include -I/usr/include/libxml2 -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include/ -I/usr/include/glibmm-2.4/ -I/usr/lib/glibmm-2.4/include/ -I/usr/include/sigc++-2.0/ -I/usr/lib/sigc++-2.0/include/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/cern/gettext/0.18.2/include/ myAnalyze.cc -o /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.o
g++ -c -I/cern/CLHEP/2.0.4.5/include/ -I/home/morad/Musique/workdir/layout -I/home/morad/Musique/workdir/library/tklibs -I/cern/ROOT/source/root/include -I/usr/include/freetype2/freetype/ -I/usr/include/freetype2 -I/cern/Minuit2/5.28.00/include -I/usr/include/libxml2 -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include/ -I/usr/include/glibmm-2.4/ -I/usr/lib/glibmm-2.4/include/ -I/usr/include/sigc++-2.0/ -I/usr/lib/sigc++-2.0/include/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/cern/gettext/0.18.2/include/ runAnalyze.cxx -o /home/morad/Musique/workdir/layout/build/analyze/runAnalyze.o
g++ -O2 -g -fopenmp -L/home/morad/Musique/workdir/library/tklibs/lib -L/home/morad/Musique/workdir/layout/lib -lxmlgeom -ltrack -lcross -lMaterialEffects -lPropagators -ltracking -lgeom -lStatUtilities -lAnalyticalJacobians -ltkhist -lxmltkgeom -lutils -lopt -ldraw -lanalyze -L/usr/lib -lGeomPropagators -lPatternPrimitives -lSurfaceGeometry -lBaseMagneticField -lUI -lGenUtil -lSiPixelDet -lSmearingClusterizers -lBasicDet -lTrackFitters -lTkFastSimHit -lCommonStripDet -lDetLayout -lTkLayout -lDetGeometry -lKalmanUpdators -lTkCommonDet -lPatternTools -lTrajectoryParametrization -lBasicStripDet -lDetUtilities -lDetVolumeGeometry -lPatternTestTools -lRKPropagators -lTkNavigation -lNumericalJacobians -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 -L/cern/ROOT/source/root/lib -L/cern/Minuit2/5.28.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -lz /usr/lib/libbz2.so.1.0.6 -lpthread -lm -ldl -lMinuit2 -L/cern/CLHEP/2.0.4.5/lib/ -lCLHEP-2.0.4.5 /usr/lib/libstdc++.so.6 /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.o /home/morad/Musique/workdir/layout/build/analyze/runAnalyze.o -o runAnalyze.exe
/home/morad/Musique/workdir/library/tklibs/lib/libSmearingClusterizers.so: undefined reference to `TrivialROUSetter::set(Module)'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `FixTIDTopology::recreateTopologies()'
/home/morad/Musique/workdir/library/tklibs/lib/libSmearingClusterizers.so: undefined reference to `TkDetTypeName::shortName(DetType const&)'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `DetUnitGluer::glue(__gnu_cxx::__normal_iterator<DetUnit**, std::vector<DetUnit*, std::allocator<DetUnit*> > >, __gnu_cxx::__normal_iterator<DetUnit**, std::vector<DetUnit*, std::allocator<DetUnit*> > >, __gnu_cxx::__normal_iterator<DetUnit**, std::vector<DetUnit*, std::allocator<DetUnit*> > >, __gnu_cxx::__normal_iterator<DetUnit**, std::vector<DetUnit*, std::allocator<DetUnit*> > >)'
/home/morad/Musique/workdir/library/tklibs/lib/libTkFastSimHit.so: undefined reference to `RawHepEventFactoryFromGun::RawHepEventFactoryFromGun()'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `toa::operator()(int const&) const'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `FixTIDTopology::FixTIDTopology()'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `DetBlade::DetBlade(__gnu_cxx::__normal_iterator<Det* const*, std::vector<Det*, std::allocator<Det*> > >, __gnu_cxx::__normal_iterator<Det* const*, std::vector<Det*, std::allocator<Det*> > >)'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `toa::~toa()'
/home/morad/Musique/workdir/library/tklibs/lib/libTkLayout.so: undefined reference to `FullTracker::instance()'
collect2: erreur: ld a retourné 1 code d'état d'exécution
make: *** [runAnalyze] Erreur 1
morad@linux-nzlc:~/Musique/workdir/layout/analyze>
*****************************************
which is not defined in *.so for example TrivialROUSetter is only declared in a file.h is not defined in file.cc I have a hunch that the g+ + compiler for opensuse needs a flags for is seeking definitions includes *. h if it is necessary unlike g+ + mac-os
thank you in advance
This line:
 
Makefile:85: /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.d: Aucun fichier ou dossier de ce type
Means Analyze.d is used in the makefile, but cannot be found.

But that's ok, because the makefile generates one with the next line.

The problem is dependencies between the libraries. There's some library that has the code for DetUnit, that libTkLayout.so needs.

It'll need to be added as a dependency.
hello
I apologize for late, I want to say in my code I get a library from multiple files. * o. So DetUnit is not a library but a script. h and. cc after compilation i get DetUnit.o and DetUnit.d by linker these objfiles:
********************
morad@linux-nzlc:~/Musique/workdir/library/tklibs/CommonDet/BasicDet> ls
BuildFile doc interface objfiles src
morad@linux-nzlc:~/Musique/workdir/library/tklibs/CommonDet/BasicDet> ls objfiles/
AlignmentPositionError.d BasicRecHit2DPosDirX.o CachingLinkingSimDet.d CmsimDetType.o DetType.d DigiSimLink.o Readout.d RecHitPrint.o
AlignmentPositionError.o BasicRecHit4D.d CachingLinkingSimDet.o CompositeDet.d DetType.o Enumerators.d Readout.o SimHit.d
BasicRecHit1D.d BasicRecHit4D.o CachingRecHit.d CompositeDet.o DetUnit.d Enumerators.o RecHit.d SimHit.o
BasicRecHit1D.o BasicRecHit.d CachingRecHit.o DaqMasterBase.d DetUnitMeasurements.d InvalidRecHit.d RecHitEqualByChannels.d TrajectoryMeasurement.d
BasicRecHit2D.d BasicRecHit.o CachingSimDet.d DaqMasterBase.o DetUnitMeasurements.o InvalidRecHit.o RecHitEqualByChannels.o TrajectoryMeasurement.o
BasicRecHit2D.o BasicRecHitPos2DEnergy.d CachingSimDet.o Det.d DetUnit.o MeasurementEstimator.d RecHit.o
BasicRecHit2DPosDirX.d BasicRecHitPos2DEnergy.o CmsimDetType.d Det.o DigiSimLink.d MeasurementEstimator.o RecHitPrint.d
morad@linux-nzlc:~/Musique/workdir/library/tklibs/CommonDet/BasicDet>
**********************************************************
i will get this library libBasicDet.so
Last edited on
Don't worry about all the .d files. They're just an inconvenience right now. They just contain .o: .h file dependencies. They have to be generated, then reread by the make file. And all that messing around is a little distracting, so just ignore them for now. They're only useful when you have a working system.

I don't understand why you have two files compiling to the same object file, surely there should be just one. This is an extract form above that I am concerned about:
1
2
g++ -c ... myAnalyze.cc -o /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.o
g++ -c ... runAnalyze.cxx -o /home/morad/Musique/workdir/layout/build/analyze/runAnalyze.o


Also, you seem to be generating a .exe file on Linux.
g++ ... -lxmlgeom -ltrack -lcross -lMaterialEffects -lPropagators -ltracking -lgeom -lStatUtilities -lAnalyticalJacobians -ltkhist -lxmltkgeom -lutils -lopt -ldraw -lanalyze ... -lGeomPropagators -lPatternPrimitives -lSurfaceGeometry -lBaseMagneticField -lUI -lGenUtil -lSiPixelDet -lSmearingClusterizers -lBasicDet -lTrackFitters -lTkFastSimHit -lCommonStripDet -lDetLayout -lTkLayout -lDetGeometry -lKalmanUpdators -lTkCommonDet -lPatternTools -lTrajectoryParametrization -lBasicStripDet -lDetUtilities -lDetVolumeGeometry -lPatternTestTools -lRKPropagators -lTkNavigation -lNumericalJacobians -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 ... -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lfreetype -lz /usr/lib/libbz2.so.1.0.6 -lpthread -lm -ldl -lMinuit2 -L/cern/CLHEP/2.0.4.5/lib/ -lCLHEP-2.0.4.5 /usr/lib/libstdc++.so.6 /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.o /home/morad/Musique/workdir/layout/build/analyze/runAnalyze.o -o runAnalyze.exe


Anyway, ignoring all that, it seems libBasicDet.so is missing form the link line (directly above). I would expect to see a -lBasicDet entry in that long lib spec.
Last edited on
I have two files to compile but they are different I show you here:
*************************************
morad@linux-nzlc:~/Musique/workdir/layout/analyze> ls
dRHits.C levelArms.C Makefile~ myAnalyze.cc.old -O3 resTh.C runAnalyze.cxx~ sigmaSqrtN.C xmldata
hadd.C localErrorFirstSiliconLayer.C materialResults.C myAnalyze.h plots0.C resTh_C.d s sqrtN.C zImpactParameter.C
helix.C Makefile myAnalyze.cc myAnalyze.h~ plots1.C resThKl.C sigmaDmPt.C toto
lanceRunAnalyze.py #Makefile# myAnalyze.cc~ myDraw.C residualInvPt.C runAnalyze.cxx sigmaInvPt.C varProcess.C
morad@linux-nzlc:~/Musique/workdir/layout/analyze>
**************************
they will be compiled by Makfile.here is the command in the makfile to compile this:
all: $(MAIN_PROG)

$(OBJDIR)/$(MAIN_PROG).o : $(MAIN_PROG).cxx
$(CXX) -c -g $(CXXFLAGS) $(CINCLAY) $< -o $@

$(MAIN_PROG) : $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o
# @echo "---- " $(CILIBLAY)
$(CXX) -fopenmp $(CILIBLAY) $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o -o $(MAIN_PROG).exe
#-undefined dynamic_lookup
$(OBJDIR)/%.o : %.cc
$(CXX) -c -g $(CXXFLAGS) $(CINCLAY) $< -o $@

include $(sources:%.cc=$(OBJDIR)/%.d)

clean :
rm $(OBJDIR)/*.d $(OBJDIR)/*.o $(LIBNAME)
************************************************************
from this i want to generate the executable by this command:
****************************
$(CXX) -fopenmp $(CILIBLAY) $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o -o $(MAIN_PROG).exe
*************************************
this is a complex code will be compiled with g+ + and flags here is the command in the makfile :
**********************
OBJDIR := /home/morad/Musique/workdir/layout/build/analyze
sources := $(wildcard *.cc)

BASENAMES_FILES = $(basename $(sources))
objfiles = $(addsuffix .d,$(BASENAMES_FILES))
OUT_OBJS = $(addprefix $(OBJDIR)/,$(objfiles))


# include and libs paths paths
C++INC := -I/usr/include/c++/4.7

CLHEPDIR_INC := -I/cern/CLHEP/2.0.4.5/include/

CLHEPDIR_LIB := -L/cern/CLHEP/2.0.4.5/lib/

CLHEPDIR_LIBS := -lCLHEP-2.0.4.5

LOCALINC := -I/home/morad/Musique/workdir/layout -I/home/morad/Musique/workdir/library/tklibs

ALPINEDIR_INC := -I/home/morad/Musique/workdir/library/tklibs

ALPINEDIR_LIB := -L/home/morad/Musique/workdir/library/tklibs/lib -L/home/morad/Musique/workdir/layout/lib -lxmlgeom -ltrack -lcross -lMaterialEffects -lPropagators -ltracking -lgeom -lStatUtilities -lAnalyticalJacobians -ltkhist -lxmltkgeom -lutils -lopt -ldraw -lanalyze

ALPINEDIR_LIBS:= -lGeomPropagators -lPatternPrimitives -lSurfaceGeometry -lBaseMagneticField -lUI -lGenUtil -lSiPixelDet -lSmearingClusterizers -lBasicDet -lTrackFitters -lTkFastSimHit -lCommonStripDet -lDetLayout -lTkLayout -lDetGeometry -lKalmanUpdators -lTkCommonDet -lPatternTools -lTrajectoryParametrization -lBasicStripDet -lDetUtilities -lDetVolumeGeometry -lPatternTestTools -lRKPropagators -lTkNavigation -lNumericalJacobians

ROOTDIR_INC := -I/cern/ROOT/source/root/include -I/usr/include/freetype2/freetype/ -I/usr/include/freetype2

ROOTDIR_LIB := -L/cern/ROOT/source/root/lib /usr/lib/libX11.so

ROOTDIR_LIBS := -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix\
-lPhysics -lMathCore -lThread -lfreetype -lz /usr/lib/libbz2.so.1.0.6 -pthread -Wl,-rpath,/cern/ROOT/source/root/lib -lpthread -lm -ldl

XMLDIR_INC := -I/usr/include/libxml2 -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include/ -I/usr/include/glibmm-2.4/ -I/usr/lib/glibmm-2.4/include/ -I/usr/include/sigc++-2.0/ -I/usr/lib/sigc++-2.0/include/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/cern/gettext/0.18.2/include/
XMLDIR_LIB := -L/usr/lib

XMLDIR_LIBS := -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 /usr/lib/preloadable_libintl.so

MINUITDIR_INC := -I/cern/Minuit2/5.28.00/include
MINUITDIR_LIB := -L/cern/Minuit2/5.28.00/lib
MINUITDIR_LIBS := -lMinuit2
#CPPPATH :=


CILIBLAY = $(ALPINEDIR_LIB) $(XMLDIR_LIB) $(ALPINEDIR_LIBS) $(XMLDIR_LIBS) $(ROOTDIR_LIB) $(MINUITDIR_LIB) $(ROOTDIR_LIBS) $(MINUITDIR_LIBS) $(CLHEPDIR_LIB) $(CLHEPDIR_LIBS) /usr/lib/libstdc++.so.6 /lib/libutil-2.15.so /lib/libSegFault.so
CINCLAY = $(CLHEPDIR_INC) $(LOCALINC) $(ROOTDIR_INC) $(MINUITDIR_INC) $(XMLDIR_INC)

MAIN_PROG = $(mainP)

#CXXFLAGS = -g -O2 -fPIC -Wall -D_GNU_SOURCE

CXXFLAGS =-m32 -O2
#-m32 -fPIC -Wall -D_GNU_SOURCE
CXX = g++
*******************
this is my librery generated in the first step
*****************
morad@linux-nzlc:~/Musique/workdir/library/tklibs/lib> ls
libAnalyticalJacobians.so libDetGeometry.so libGeomPropagators.so libPatternTestTools.so libSmearingClusterizers.so libTkLayout.so
libBaseMagneticField.so libDetLayout.so libKalmanUpdators.so libPatternTools.so libStatUtilities.so libTkNavigation.so
libBasicDet.so libDetUtilities.so libMaterialEffects.so libPropagators.so libSurfaceGeometry.so libTrackFitters.so
libBasicStripDet.so libDetVolumeGeometry.so libNumericalJacobians.so libRKPropagators.so libTkCommonDet.so libTrajectoryParametrization.so
libCommonStripDet.so libGenUtil.so libPatternPrimitives.so libSiPixelDet.so libTkFastSimHit.so libUI.so
morad@linux-nzlc:~/Musique/workdir/layout/lib> ls
libanalyze.so libcross.so libdraw.so libgeom.so libopt.so libtkhist.so libtracking.so libtrack.so libutils.so libxmlgeom.so libxmltkgeom.so
morad@linux-nzlc:~/Musique/workdir/layout/lib>
*****************************

If you're on Linux, why do your executables have .exe extensions?

I take it the tabs have been lost because you've not used the code format tag.

I take it the first makefile works and the second one is problematic. Is that right? I'll just comment on the second one from here.

I'm not clear on why you need to specify the compiler include file (with C++INC) and the C++ runtime libs (in CILIBLAY). Linking with g++ (or icc) will find them. However, I can't be sure that C++INC is actually used.

The problematic -lBasicDet is present (in ALPINEDIR_LIBS), so that's ok. And it appears before the complaining libTKLayout, so that's good too.

I would expect that custom compile line to appear after those macro definitions. But I can't see where it appears or the rule that invokes it.
 
$(CXX) -fopenmp $(CILIBLAY) $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o -o $(MAIN_PROG).exe


Going back to your original post, ...

Don't mix -g and -O2.

TrivialROUSetter is only declared in a file.h is not defined in file.cc I have a hunch that the g+ + compiler for opensuse needs a flags for is seeking definitions includes *. h if it is necessary unlike g+ + mac-os
The behaviour of gcc is consistent across platforms except where there are platform variances.

Anyway, if the methods of TrivialROUSetter are defined as inline and are accessible from the .h file, then it ought to be ok. Does the .h have the implementation of the methods or just the definitions?

Also, you should order the link such that the local objs appear first, then the shared libs. With gcc, the order is important. It will ignore duplicate symbols in following libs. Your lib appears before the object files. You should fix that.

Lets just go thru them one at a time.

Where does the implementation for TrivialROUSetter::set(Module) live? Is it in a .h file? If so is it inline? If it's in a compiled module, does the linker see it before the module that uses it?

Apply the same reasoning to each of the problem symbols:
FixTIDTopology::recreateTopologies() accessed from libTkLayout.so
TkDetTypeName::shortName(DetType const&) accessed from libSmearingClusterizers.so
DetUnitGluer::glue accessed from libTkLayout.so ...
Last edited on
thank you very much for that motivation,
I said that code is run mac-os there is nothing to change it is only necessary to find an option to the flags for g+ +. I've encountered this kind of problem in the first step in creating libraries *. so, but fortunately I found a option FLAGS -shred to link the objfiles mac-os we don't need this FLAGS, the compiler mac-os is oawesome ,only g+ + is sufficient to generate the *. so from *. o it understands that is a lib and not an objfiles .o
My point about ordering the input is that the GNU linker ignores duplicate symbols that appear later on. So it's important to specify the obj files before the lib files on Linux, I can't remember running into the problem on OS X.

This is particularly anoying because the default GNU makefile rule specifies the libraries first, then the objs. This is because the rule is:
 
${LINK.cc)
which is:
 
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
and the libs tend to get added to LDFLAGS and the object and target get specified at the end as in:
 
${LINK.cc) -o $@ $^


My lib rules tend to look like:
1
2
3
4
5
$(NAME.so): $(OS_FILES)
    $(LINK.cc) -shared -o $@ $^

$(NAMEa): $(O_FILES)
    ar rcs $@ $^


I can't really think of anything else from what you've sent me.
this is my makfile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 # this Makefile compiles all the *.cc files in the current directory
# It generates the dependencies automatically, following the example at
# info:/make/Automatic Prerequisites
# names of cc files without suffixe
# -------------
# The Prerequisites and object files will be writen in objfiles
#---------------


OBJDIR := /home/morad/Musique/workdir/layout/build/analyze
sources := $(wildcard *.cc)

BASENAMES_FILES = $(basename $(sources)) 
objfiles = $(addsuffix .d,$(BASENAMES_FILES))
OUT_OBJS = $(addprefix $(OBJDIR)/,$(objfiles))
# include and libs paths paths 
CLHEPDIR_INC  := -I/cern/CLHEP/2.0.4.5/include/

CLHEPDIR_LIB  := -L/cern/CLHEP/2.0.4.5/lib/

CLHEPDIR_LIBS := -lCLHEP-2.0.4.5

LOCALINC      := -I/home/morad/Musique/workdir/layout -I/home/morad/Musique/workdir/library/tklibs 

ALPINEDIR_INC := -I/home/morad/Musique/workdir/library/tklibs

ALPINEDIR_LIB := -L/home/morad/Musique/workdir/library/tklibs/lib -L/home/morad/Musique/workdir/layout/lib  -lxmlgeom -ltrack -lcross -lMaterialEffects -lPropagators -ltracking -lgeom -lStatUtilities -lAnalyticalJacobians -ltkhist -lxmltkgeom -lutils -lopt -ldraw -lanalyze

ALPINEDIR_LIBS:= -lTkLayout -lDetGeometry -lKalmanUpdators  -lDetVolumeGeometry -lPatternTestTools -lRKPropagators -lTkCommonDet -lPatternTools -lTrajectoryParametrization -lBasicStripDet -lDetUtilities -lBasicDet -lGeomPropagators -lPatternPrimitives -lSurfaceGeometry -lBaseMagneticField -lUI -lGenUtil -lSiPixelDet -lSmearingClusterizers -lTrackFitters -lTkFastSimHit -lCommonStripDet -lDetLayout  -lTkNavigation -lNumericalJacobians 

ROOTDIR_INC   := -I/cern/ROOT/source/root/include  -I/usr/include/freetype2/freetype/  -I/usr/include/freetype2 

ROOTDIR_LIB   := -L/cern/ROOT/source/root/lib  /usr/lib/libX11.so

ROOTDIR_LIBS  := -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix\
		 -lPhysics -lMathCore -lThread -lfreetype -lz  /usr/lib/libbz2.so.1.0.6  -pthread -Wl,-rpath,/cern/ROOT/source/root/lib -lpthread  -lm -ldl

XMLDIR_INC    := -I/usr/include/libxml2 -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include/ -I/usr/include/glibmm-2.4/ -I/usr/lib/glibmm-2.4/include/ -I/usr/include/sigc++-2.0/ -I/usr/lib/sigc++-2.0/include/ -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ -I/cern/gettext/0.18.2/include/    
XMLDIR_LIB    := -L/usr/lib

XMLDIR_LIBS   := -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0  /usr/lib/preloadable_libintl.so

MINUITDIR_INC := -I/cern/Minuit2/5.28.00/include
MINUITDIR_LIB := -L/cern/Minuit2/5.28.00/lib
MINUITDIR_LIBS := -lMinuit2 
#CPPPATH := 
CILIBLAY = $(ALPINEDIR_LIB)  $(XMLDIR_LIB)  $(ALPINEDIR_LIBS) $(XMLDIR_LIBS) $(ROOTDIR_LIB) $(MINUITDIR_LIB) $(ROOTDIR_LIBS) $(MINUITDIR_LIBS) $(CLHEPDIR_LIB) $(CLHEPDIR_LIBS)  /usr/lib/libstdc++.so.6 /lib/libutil-2.15.so /lib/libSegFault.so
CINCLAY =  $(CLHEPDIR_INC) $(LOCALINC) $(ROOTDIR_INC) $(MINUITDIR_INC) $(XMLDIR_INC)    

MAIN_PROG = $(mainP)

#CXXFLAGS = -g -O2 -fPIC -Wall -D_GNU_SOURCE 

CXXFLAGS =-m32 
#-m32 -fPIC -Wall -D_GNU_SOURCE
CXX = g++ 
#-D_GNU_SOURCE 

$(OBJDIR)/%.d: %.cc
	$(CXX) -MM $(CXXFLAGS) $(CINCLAY)  $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$

objfiles := $(addsuffix .o,$(BASENAMES_FILES))
OUT_OBJS := $(addprefix $(OBJDIR)/,$(objfiles))

all: $(MAIN_PROG)

$(OBJDIR)/$(MAIN_PROG).o : $(MAIN_PROG).cxx
	$(CXX) -c -g $(CXXFLAGS) $(CINCLAY) $< -o $@

$(MAIN_PROG) : $(OUT_OBJS) $(OBJDIR)/$(MAIN_PROG).o
#	@echo "---- " $(CILIBLAY)
	$(CXX) -fopenmp  $(CILIBLAY)  $(OUT_OBJS)  $(OBJDIR)/$(MAIN_PROG).o -o $(MAIN_PROG)
#-undefined dynamic_lookup
$(OBJDIR)/%.o : %.cc 
	$(CXX) -c -g $(CXXFLAGS) $(CINCLAY)  $< -o $@  

include $(sources:%.cc=$(OBJDIR)/%.d)

clean :
	rm $(OBJDIR)/*.d $(OBJDIR)/*.o $(LIBNAME) */
is it good?
Topic archived. No new replies allowed.