SebWouters / CheMPS2

CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
GNU General Public License v2.0
70 stars 34 forks source link

Undefined reference to 'XXX', such as`CheMPS2::Initialize::Init()' while compling test1.cpp #17

Closed dingld closed 9 years ago

dingld commented 9 years ago

I succeeded in installing Chemps2 as guided, and "make test" actually went well. But thins went wrong when I complile test1.cpp using icpc. ( the same issue using g++) 2015-08-20 22 43 55 2015-08-20 22 29 40

SebWouters commented 9 years ago

Hi,

You need to pass the folder with the include files to the compiler. If you type the following in your build folder, you will see how to:

make clean
make VERBOSE=1

On my machine, this gives:

cd /home/seba/Desktop/CheMPS2_github/build/tests && /opt/intel/composer_xe_2015.0.090/bin/intel64/icpc    -g -O3  -openmp -xHost -ipo -I/home/seba/Desktop/CheMPS2_github/CheMPS2/include/chemps2    -o CMakeFiles/test9.dir/tests/test9.cpp.o -c /home/seba/Desktop/CheMPS2_github/build/tests/tests/test9.cpp

The relevant part for your error is

-I/home/seba/Desktop/CheMPS2_github/CheMPS2/include/chemps2

I hope this helps! If not or in case you have other questions, let me know!

Best wishes, Sebastian

dingld commented 9 years ago

In the first place I thought the same with you. Then I copied the head files to /usr/include, that is why in the picture above I didn't add include-path. But the compile complains quite similarly. I did as you told, and here is what I got. ( I have deleted the head file in /usr/inlcude, and assign path when compiling ) 2015-08-20 23 46 15

SebWouters commented 9 years ago

Hi,

So if you have installed with

make install

you either need to specify the headers in your file.ccp as

#include "chemps2/theheader.h"

instead of

#include "theheader.h",

or compile with the full header path by passing it to the compiler:

icpc -g -O3 -openmp -xHost -ipo -fPIC -I/usr/include/chemps2 -o file.o -c file.cpp
icpc -g -O3 -openmp -xHost -ipo file.o -o mybin -L/usr/lib/x86_64-linux-gnu -lchemps2

Can you try with the exact same order of commands as in the two lines above?

Best wishes, Sebastian