# Compilation problem of stand alone program

**URL:** <https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901>\
**Category:** ROOT\
**Created:** [March 1, 2012, 9:39pm UTC](https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901 "2012-03-01T21:39:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rootuser01](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rootuser01](https://root-forum.cern.ch/u/rootuser01)\
**Post date:** [March 1, 2012, 9:39pm UTC](https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901/1 "2012-03-01T21:39:31Z")

</div>

Hello,

I just installed the new ubutu (11.10) and the version 5.32. of ROOT. I get problems in compiling a simple C++ “hello world” if I include for example a TH1F.h. In this case I get a “\_\_static\_initialization\_and\_destruction\_0” error.

I explain all the steps I have done in the following:  
I installed Ubuntu 11.10  
I installed all prerequisites Ubuntu 9, 10 and 11  
Then download root, unpack it and do:

```auto
cd root
./configure
make
. bin/thisroot.sh
```

Then I do

```auto
export ROOTSYS=$HOME/root
export PATH=$PATH:$ROOTSYS/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
```

CINT works fine. I can load and execute macro. But I cannot use my Makefile which was always working on previous versions and also on MAC. My Makefile is:

```auto
CXX = g++
LD = g++

OS_NAME:=$(shell uname -s | tr A-Z a-z)
ifeq ($(OS_NAME),darwin)
INCDIR:=/opt/local/include
LIBDIR:=/opt/local/lib
else
INCDIR:=/usr/include
LIBDIR:=/usr/lib
endif

LDFLAGS := $(shell root-config --libs --glibs) -L$(LIBDIR) 
CPPFLAGS := $(shell root-config --cflags) -I$(INCDIR)

CPPFLAGS += -g

TARGET = test

SRC = main.cpp

OBJ = $(SRC:.cpp=.o) 

all : $(TARGET)

$(TARGET) : $(OBJ)
	$(LD) $(CPPFLAGS) $(LDFLAGS) $(OBJ) -o $(TARGET)

%.o : %.cpp
	$(CXX) $(CPPFLAGS) -c $< -o $@

clean :
	rm -f *.o $(TARGET)

```

with the simple main.cpp:

```auto
#include <iostream>
#include <TH1F.h>
using namespace std;
int main(int argc, char *argv[])
{
	cout<<"Hello world"<<endl;
        return 0;
}
```

when I compile I get this :

```auto
user@ubuntu:~/Work/code/test$ make
g++ -pthread -m64 -I/home/user/root/include -I/usr/include -g -L/home/user/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -L/home/user/root/lib -lGui -L/usr/lib main.o -o test
main.o: In function `__static_initialization_and_destruction_0':
/home/user/root/include/TVersionCheck.h:34: undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [test] Erreur 1
```

I have no idea where the problem is. Any help would be great!  
Thank you

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 2, 2012, 12:34am UTC](https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901/2 "2012-03-02T00:34:05Z")

</div>

Try the attached Makefile.  
Also … use either: `export ROOTSYS=$HOME/root
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH` … or better … simply execute: `source $HOME/root/bin/thisroot.sh`  
[Makefile.txt](https://root-forum.cern.ch/uploads/default/original/2X/f/f5d08e56b042b875f7395a4022df488dd8af8af9.txt) (581 Bytes)

---

<div class="post-metadata">

**Author:** ![rootuser01](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rootuser01](https://root-forum.cern.ch/u/rootuser01)\
**Post date:** [March 2, 2012, 8:12am UTC](https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901/3 "2012-03-02T08:12:48Z")

</div>

Hi Pepe Le Pew,

thank you very much, this is working fine now!!  
However I still don t understand why my procedure didn’t work. It was working in previous version of ubuntu and/or root. Is it the new Ubuntu that makes problem?

Thanks again.

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 2, 2012, 8:56am UTC](https://root-forum.cern.ch/t/compilation-problem-of-stand-alone-program/13901/4 "2012-03-02T08:56:24Z")

</div>

See also: [url][Linking problem to libTree.so](https://root-forum.cern.ch/t/linking-problem-to-libtree-so/13697/1)
