RE: [ROOT] Trying to link against root libraries

From: Philippe Canal (pcanal@fnal.gov)
Date: Tue Jun 24 2003 - 23:45:07 MEST


Hi John,

The command line is missing the list of ROOT libraries:
	g++ -g ObjDate.o TradeEvent.o Nasdaq.o    -lm -ldl -rdynamic -o Nasdaq
Your Makefile (as enclosed) says:
  $(NASDAQ):	$(OBJS)
   		$(LD) $(LDFLAGS) $(OBJS) $(LIBS) $(OutPutOpt) $(NASDAQ)
and
  LIBS          = $(ROOTLIBS)  -lm -ldl -rdynamic
and
  ROOTLIBS      = -L$(ROOTSYS)/lib -lNew  -lCint -lClib -lCont -lFunc \
                 -lGraf -lGraf3d -lHist -lHtml -lMatrix -lMeta -lMinuit -lNe
t \
                 -lPostscript -lProof -lTree -lUnix -lZip
so they __should__ have been there.  However it looks like the variable
ROOTLIBS is empty.

You can use something like:
  DEBUG := $(shell echo ROOTLIBS is --$(ROOTLIBS)-- 1>&2)
to debug when and where the variable ROOTLIBS is (un)initialized.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Dr. John Krane
Sent: Tuesday, June 24, 2003 4:17 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Trying to link against root libraries


Hi,

I'm trying to build a stand-alone executable, but I get errors like
those below, followed by a horde or "undefined reference" complaints
that do not contain the words "in-charge".  I'm running

Linux 9.0.1, gcc 3.2.2-5, root 3.05/5 + MySQL built by me (ouch!)

I include my makefile below the list of the first few errors.  I should
say that ROOT makes a .so file with no complaints of each of my sources.
  I do not understand why gcc does not like linking the stuff.  I am
hoping I just did something dumb in my makefile...  Any help appreciated!

	- John

[jkrane@localhost treemaker]$ make all
g++ -g ObjDate.o TradeEvent.o Nasdaq.o    -lm -ldl -rdynamic -o Nasdaq
ObjDate.o(.text+0x19): In function `ObjDate::ObjDate[not-in-charge]()':
: undefined reference to `TObject::TObject[not-in-charge]()'
ObjDate.o(.text+0x91): In function `ObjDate::ObjDate[in-charge]()':
: undefined reference to `TObject::TObject[not-in-charge]()'
ObjDate.o(.text+0x109): In function
`ObjDate::ObjDate[not-in-charge](char const*, char const*)':
: undefined reference to `TObject::TObject[not-in-charge]()'
ObjDate.o(.text+0x2c7): In function `ObjDate::ObjDate[in-charge](char
const*, char const*)':
: undefined reference to `TObject::TObject[not-in-charge]()'
ObjDate.o(.text+0x48f): In function `ObjDate::~ObjDate [not-in-charge]()':
: undefined reference to `TObject::~TObject [not-in-charge]()'
ObjDate.o(.text+0x4bf): In function `ObjDate::~ObjDate [in-charge]()':
: undefined reference to `TObject::~TObject [not-in-charge]()'
ObjDate.o(.text+0x4f0): In function `ObjDate::~ObjDate [in-charge
deleting]()':
: undefined reference to `TObject::~TObject [not-in-charge]()'
ObjDate.o(.text+0x4f8): In function `ObjDate::~ObjDate [in-charge
deleting]()':
: undefined reference to `TObject::operator delete(void*)'
ObjDate.o(.text+0x8c7): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `ROOT::GenerateInitInstance(ObjDate const*)'
ObjDate.o(.text+0x8cf): In function
`__static_initialization_and_destruction_0(int, int)':



ObjSuf        = o
SrcSuf        = cpp
ExeSuf        =
DllSuf        = so
EVENTLIB      = $(EVENTO)
OutPutOpt     = -o

#ROOTLIBS      = -L$(ROOTSYS)/lib -lNew -lBase -lCint -lClib -lCont -lFunc \
ROOTLIBS      = -L$(ROOTSYS)/lib -lNew  -lCint -lClib -lCont -lFunc \
                 -lGraf -lGraf3d -lHist -lHtml -lMatrix -lMeta -lMinuit
-lNet \
                 -lPostscript -lProof -lTree -lUnix -lZip
ROOTGLIBS     = -lGpad -lGui -lGX11 -lX3d


+SELF,IF=LINUX,IF=-EGCS.
# Linux
CXX           = g++
CXXFLAGS      = -O -Wall -fPIC -I$(ROOTSYS)/include
LD            = g++
LDFLAGS       = -g
SOFLAGS       = -Wl,-soname,libEvent.so -shared
#LIBS          = $(ROOTLIBS) -lg++ -lm -ldl -rdynamic
LIBS          = $(ROOTLIBS)  -lm -ldl -rdynamic
GLIBS         = $(ROOTLIBS) $(ROOTGLIBS) -L/usr/X11R6/lib \
                 -lXpm -lX11 -lg++ -lm -ldl -rdynamic

#+SELF,IF=LINUX,IF=EGCS.
# Linux with egcs
#CXX           = g++
#CXXFLAGS      = -O -Wall -fno-rtti -fno-exceptions -fPIC
-I$(ROOTSYS)/include
#LD            = g++
#LDFLAGS       = -g
#SOFLAGS       = -Wl,-soname,libEvent.so -shared
#LIBS          = $(ROOTLIBS) -lm -ldl -rdynamic
#GLIBS         = $(ROOTLIBS) $(ROOTGLIBS) -L/usr/X11R6/lib \
#                -lXpm -lX11 -lm -ldl -rdynamic



#---------------------------------------------------------------------------
---

OBJDATEO      = ObjDate.$(ObjSuf)
EVENTO        = TradeEvent.$(ObjSuf)
NASDAQO       = Nasdaq.$(ObjSuf)

OBJDATES      = ObjDate.$(SrcSuf)
EVENTS        = TradeEvent.$(SrcSuf)
NASDAQS       = Nasdaq.$(SrcSuf)

NASDAQ        = Nasdaq$(ExeSuf)

OBJS          = $(OBJDATEO) $(EVENTO) $(NASDAQO)

PROGRAMS      = $(NASDAQ)

all:            $(PROGRAMS)

#		$(LD) $(LDFLAGS) $(OBJS) $(GLIBS) $(OutPutOpt) $(NASDAQ)
$(NASDAQ):	$(OBJS)
		$(LD) $(LDFLAGS) $(OBJS) $(LIBS) $(OutPutOpt) $(NASDAQ)
		@echo "$(NASDAQ) done"


clean:
		@rm -f $(OBJS) core

.SUFFIXES: .$(SrcSuf)

###


.$(SrcSuf).$(ObjSuf):
	$(CXX) $(CXXFLAGS) -c $<



#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET