problem in my dynamic lib*.so

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/
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/ -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/ > /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/ -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/ -o /home/morad/Musique/workdir/layout/build/analyze/myAnalyze.o
g++ -c -I/cern/CLHEP/ -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/ -lpthread -lm -ldl -lMinuit2 -L/cern/CLHEP/ -lCLHEP- /usr/lib/ /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/ undefined reference to `TrivialROUSetter::set(Module)'
/home/morad/Musique/workdir/library/tklibs/lib/ undefined reference to `FixTIDTopology::recreateTopologies()'
/home/morad/Musique/workdir/library/tklibs/lib/ undefined reference to `TkDetTypeName::shortName(DetType const&)'
/home/morad/Musique/workdir/library/tklibs/lib/ 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/ undefined reference to `RawHepEventFactoryFromGun::RawHepEventFactoryFromGun()'
/home/morad/Musique/workdir/library/tklibs/lib/ undefined reference to `toa::operator()(int const&) const'
/home/morad/Musique/workdir/library/tklibs/lib/ undefined reference to `FixTIDTopology::FixTIDTopology()'
/home/morad/Musique/workdir/library/tklibs/lib/ 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/ undefined reference to `toa::~toa()'
/home/morad/Musique/workdir/library/tklibs/lib/ undefined reference to `FullTracker::instance()'
collect2: erreur: ld a retourné 1 code d'état d'exécution
make: *** [runAnalyze] Erreur 1
which is not defined in *.so for example TrivialROUSetter is only declared in a file.h is not defined in 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
my problem no solved on
thank you in advance

2 Answers


I think your problem is the order of the link line. On Linux, if depends upon functions from then your link line must list before i.e. this will cause an undefined symbol:

-L -lB -lA

whereas this will not:

-L -lA -lB

I do not believe that Mac has this requirement. If your .so files have circular dependencies, you can use -Wl,--start-group -lA -lB -Wl,--end-group. That will probably also remove the need to put the .so files in a particular order.


Please i recompile for link the library I met a problem the compilator gcc for opensuse gcc it Search in first time include before going out in the point that it would need these includes, for example

[code] #ifndef TimingREPORT_H
#define TimingREPORT_H
// V 1.1 01/09/2000
// Fast timing on Pentium
// on/off control introduced
// fixed format output
// V 1.2 21/02/2001
// cpu time added
// not thread safe yet...

#include <string>

#include <hash_map>
#include "Utilities/GenUtil/interface/stringhash.h"
#include <map>


#include "Utilities/Notification/interface/BaseEvent.h"
[COLOR="Green"][B] #include "CommonDet/BasicDet/interface/AlignmentPositionError.h"[/B][/COLOR]

#include "Utilities/GenUtil/interface/CMSTimers.h"

/* a class to manage Timing
class TimingReport {
typedef BaseEvent< std::pair<double,double> > ItemObserver;

class Item {
typedef BaseEvent< std::pair<double,double> > MyObserver;
Item() : on(true), cpuon(true), counter(0), o(0){}
Item & switchOn(bool ion) {on=ion; return *this;}
Item & switchCPU(bool ion) {cpuon=ion; return *this;}
void start() { if (on) {counter++; if (cpuon) cpuwatch.start(); stopwatch.start(); }}
void stop(){
if (on) {
if (cpuon) cpuwatch.stop();
if (active()) return;
if (o) (*o)(std::pair<double,double>(stopwatch.lap().seconds(),
bool active() const { return stopwatch.running();}
void setObs(MyObserver * io) { o=io;}
double realsec() const;
double realticks() const;
double cpusec() const;
bool on;
bool cpuon;
int counter;
StopWatch stopwatch;
CPUWatch cpuwatch;
MyObserver * o;


static TimingReport * current();


typedef hash_map< std::string, Item, hash<std::string>, std::equal_to<std::string> > SMAP;
typedef std::map< std::string, Item, std::less<std::string> > SMAP;



void dump(std::ostream & co, bool active=false);

/// report in ticks
bool & inTicks() { return inTicks_;}

/// switch all on
void switchOn(bool ion);

/// switch one ion
void switchOn(const std::string& name, bool ion) {

void start(const std::string& name) {
if(on) registry[name].start();
void stop(const std::string& name) {
if (on) registry[name].stop();

Item & operator[](const std::string& name) {
SMAP::iterator p = registry.find(name);
if (p!=registry.end()) return (*p).second;
return make(name);

const Item & operator[](const std::string& name) const {
SMAP::const_iterator p = registry.find(name);
if (p!=registry.end()) return (*p).second;
return const_cast<TimingReport*>(this)->make(name);

Item & make(const std::string& name) {
return registry[name].switchOn(on);

const bool & isOn() const { return on;}


bool on;
bool inTicks_;
SMAP registry;

/** a class to time a "scope" to be used as a "Sentry".
Just create a TimeMe object giving it a name;
exiting the scope the object will be deleted;
the constuctor starts the timing.
the destructor stops it.
class TimeMe{

explicit TimeMe(const std::string& name, bool cpu=true) :
item((*TimingReport::current())[name]) {

explicit TimeMe(TimingReport::Item & iitem, bool cpu=true) :
item(iitem) {

std::pair<double,double> lap() const {
return std::pair<double,double>(item.stopwatch.lap().seconds(),

~TimeMe() {


TimingReport::Item & item;

#endif [/code]

then it asked me to check the path [COLOR = "green"] # include "CommonDet / BasicDet / interface / AlignmentPositionError.h" [/ COLOR] even if we need to file my question: [B]there is a FLAGS to redirect it [/ B]

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.


Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap