i had modified main02.cc(sample program) as mainz02.cc
when i tried to compile it using
g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I$ROOTSYS/include mainz02.cc -o mainz02
i got error as:
collect2: ld returned 1 exit status
my program is:
mainz02.cc (1.49 KB)
You have to link against libPythia8 (-L$PYTHIA8/lib -lPythia8) and some of the ROOT libraries (using ‘root-config --glibs’). See for example [url=https://root-forum.cern.ch/t/compiling-root-script-with-g/15120/3 thread[/url], or just search on this forum, there are probably several examples…
And please, don’t post several times the same question in different threads.
And you should probably ask one of your colleagues to explain how all this work. It is much better to look at this in front of a computer than exchanging posts on a forum…
should i change my makefile in pythia/examples???
This is one option. You can also make a new one, or type directly from the command line…
can you tell me the command line i should use??
i used the code:
g++ -O2 -ansi -pedantic -W -Wall -Wshadow `root-config --glibs` -L$PYTHIA8/lib -I$PYTHIA8/include -I$ROOTSYS/include mainz02.cc -o mainz02
i am still getting the same error
But you should ask your colleagues, really...
But you should ask your colleagues, really…
my colleagues are not expert in c++.They are doing physics part.I had already asked them.
It created a file mainz02 but not a file with extension .exe
This is normal on Linux… Just execute it…
mainz02.exe would be on Windows. NB if you want you can rename it:
mv mainz02 mainz02.exe
i got error as:
./mainz02: error while loading shared libraries: libCore.so: cannot open shared object file: No such file or directory
i then used
then i tried to get output using
i again got error as:
./mainz02.exe: error while loading shared libraries: libCore.so: cannot open shared object file: No such file or directory
You know you should really try to search and find solutions by yourself at some point… There are several posts on this forum asking the same kind of question, and you can easily search the forum with the “search” entry on the top right corner…
And to answer your question (just in case you didn’t find it by yourself), you have this error because $ROOTSYS/lib is not in the LD_LIBRARY_PATH. You have to execute the “thisroot.sh” (or thisroot.csh) script located in $ROOTSYS/bin, as explained for example in Installing ROOT from Source page.
And to make sure you read the right part of it, here is what it says:
Add bin/ to PATH and lib/ to LD_LIBRARY_PATH. For the sh shell family do:
and for the csh shell family do:
And please, keep the original file name, and don’t rename it with .exe
But i had built root using fixed location installation.
I had used
when i used
i got output as:
root: /etc/root /usr/local/bin/root.exe /usr/local/bin/root /usr/local/lib/root
i also has root directory in my Downloads directory as:
i also had added these lines to my .bashrc file
i also had used source .bashrc after adding these lines.
Could you post the result of “echo $PATH” and “echo $LD_LIBRARY_PATH”?
the output of
and the output of
See[quote=“raman”]and the output of
CODE: SELECT ALL
See? [color=#0000FF]/home/raman/Downloads/root/lib[/color] is missing from your $LD_LIBRARY_PATH… If you fix that everything will work.
now the output of
and my program is working now.