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

Compilation problem when trying to build a shared library #53

Closed kannon92 closed 8 years ago

kannon92 commented 8 years ago

I am trying to build the newest version of CheMPS2. I found that I can not compile a shared version of this library. I get errors that it can not find HDF5 and mkl. I get these errors only when I link with a shared library. I am able to build and successfully test a static library.

CC=clang CXX=clang++ cmake .. -DMKL=on -DCMAKE_VERBOSE_MAKEFILE=true -DSHARED_ONLY=on -DCMAKE_INSTALL_PREFIX=/Users/kevinhannon/Programs/CheMPS2/build/install

I get errors like this:

undef: _H5T_NATIVE_INT_g
undef: _dgemv_
undef: _H5Dclose
undef: _H5T_NATIVE_LLONG_g
undef: _dlange_
undef: _H5Gcreate2
undef: _ddot_
undef: _dsyev_
undef: _dlansy_
undef: _dgemm_

I also get this warning during my cmake configure:

CMake Error in CheMPS2/CMakeLists.txt:
Target "chemps2-shared" INTERFACE_INCLUDE_DIRECTORIES property contains
 path:

"/Users/kevinhannon/Programs/CheMPS2/CheMPS2//usr/local/Cellar/hdf5/1.8.17/include"

 which is prefixed in the source directory.
loriab commented 8 years ago

I assume you're on Mac? Apply this patch to CheMPS2/CMakeLists.txt

 if (NOT STATIC_ONLY)
+    if (APPLE)
+        target_link_libraries  (chemps2-shared PRIVATE "-undefined dynamic_lookup")
+    endif()
     target_compile_definitions (chemps2-shared INTERFACE USING_${PROJECT_NAME})
kannon92 commented 8 years ago

Your assumption is correct and this change worked. Thank you @loriab. I will see if I can link with my code.

loriab commented 8 years ago

Glad it worked, Kevin. Follow the model of https://github.com/jturney/psi4/commits/CMakeRewrite-KillTheBoost if it gives you any trouble.

kannon92 commented 8 years ago

Thank you, Lori. Everything seems to work perfectly well now. I am able to use ChemPS2 in my codes, so I will close this issue.