Collect2: error: ld returned 1 exit status

Hi,
In order to analyze my data in root, I have to run certain simulation, but when I try to compile it I receive an error message:
/tmp/cc8hgmN4.o: In function MAIN__': sim_pd.f:(.text+0x90c): undefined reference tohlimit_’
sim_pd.f:(.text+0x944): undefined reference to hropen_' sim_pd.f:(.text+0x985): undefined reference tohbookn_’
sim_pd.f:(.text+0xe79): undefined reference to hlimit_' sim_pd.f:(.text+0xeb6): undefined reference tohropen_’
sim_pd.f:(.text+0xef7): undefined reference to hbookn_' sim_pd.f:(.text+0x3690): undefined reference tohfn_’
sim_pd.f:(.text+0x3822): undefined reference to hrout_' sim_pd.f:(.text+0x3840): undefined reference tohldir_’
sim_pd.f:(.text+0x3864): undefined reference to rzstat_' sim_pd.f:(.text+0x3878): undefined reference tohrend_’
collect2: error: ld returned 1 exit status
Script is attached.

Please help me,
B.
sim_pd.f (17.8 KB)

These symbols are coming from CERNLIB. They are in $ROOTSYS/lib/libminicern.a

Sorry, but could you explain me more close what it means? What should I do to repair this problem?

Can you show how you link your program ?

I just tried to compile it with: gfortran -o sim_pd sim_pd.f

so you are calling root classes from fortran ? I bet not …
Looks like your program is a cernlib one not a ROOT one …

How should I link it then?

You should find out where the cernlib libraries are located on your machine … if they are …
what kind of machine are you using ?
Note that cernlib is frozen for years right now, and not supported anymore.
If your program is not to big can you post it here to see how it looks like ?

I have Ubuntu 16.04 LTS on my computer and I have installed cernlib libraries (whit root). I attach my program
sim_pd.f (17.8 KB)

Yes this is a fortran program using cernlib.

you said:

ROOT does not contain the CERNLIB library it just have a small subset of it in the .a I mentioned before. This is for internal ROOT usage only two translate HBOOK files to ROOT files.

you can try:

gfortran -o sim_pd sim_pd.f  $ROOTSYS/lib/libminicern.a

But I do not think it will work.

Is it a new program ? … it is only 800 lines… why don’t you convert you program in C++ and use supported software like ROOT ?

It is not new… How could I convert it, could you tell me? Sorry, but I am not good in programing.

Try first for like the way I suggested … it takes no time.
If it does not work try to find CERNLIB installed for Ubuntu.
If you google “cernlib for ubuntu” you will find some links.

hello again,
so, when i tried with this: gfortran -o sim_pd sim_pd.f $ROOTSYS/lib/libminicern.a but I got this message: /lib/libminicern.a: No such file or directory
then I tried to instal cernlib, I got this message:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Your variable ROOTSYS is not defined… it should be the place where you installed root. just find where libminicern.a and link with the absolute path …

how ? what have you done ?

Do you have some colleagues next to you who can help ?

Sorry, my mistake: I did this:
gfortran -o sim_pd sim_pd.f /home/bojan/root/lib/libminicern.a
and got this:
/tmp/ccbQowoD.o: In function MAIN__': sim_pd.f:(.text+0x985): undefined reference tohbookn_'
sim_pd.f:(.text+0xef7): undefined reference to hbookn_' sim_pd.f:(.text+0x3690): undefined reference tohfn_'
sim_pd.f:(.text+0x3822): undefined reference to hrout_' sim_pd.f:(.text+0x3864): undefined reference torzstat_'
collect2: error: ld returned 1 exit status

Ok so that way does not works, we tried, … the only way would be to install a ubuntu version of CERNLIB.

In your program you only book and ntuple and fill it. This can be also done with a ROOT macro. Then you will have to learn a bit of C++ and rewrite you program in this language. That might be worst the effort …

I tried to install cernlib foloving this:
installion.co.uk/ubuntu/xenial/u … index.html
but I got message that I sent you earlier:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I cannot help you with that.