Error compiling with root libraries (/usr/lib/crt1.o)

Hi Rooters,

I am using root on a RHEL system. I obatin the following output when trying to compile an executable using the attached code and Makefile. The error seems to be in the linking phase. Can anyone help?

ifarml3.jlab.org> make

g++ -MM -Wall -I/apps/root/PRO/root/include mc_sosBaseClass.C > mc_sosBaseClass.d
g++ -MM -Wall -I/apps/root/PRO/root/include mc_sosBaseClass.C | sed s/\.o/.d/ >> mc_sosBaseClass.d
g++ -Wall -I/apps/root/PRO/root/include -c -o mc_sosBaseClass.o mc_sosBaseClass.C
g++ -L/apps/root/PRO/root/lib root-config --glibs -o mc_hms_acceptfunc mc_sosBaseClass.o
/usr/lib/crt1.o(.text+0x18): In function _start': : undefined reference tomain’
collect2: ld returned 1 exit status
make: *** [mc_hms_acceptfunc] Error 1

Many thanks,
Mark
files.tar (40 KB)

Hi,
your files seem to contain only zeros. I’d assume you don’t have a “int main(…)” method in your code - you’re telling the linker to create an executable, and that needs one. If you want to create a shared library you should specify the likner flag “-shared”, and add the “.so” extension to the output file (-o …).
Cheers, Axel.