I am trying to integrate a FORTRAN library into our C++ project. I have used the following in our CMakeLists.txt file:
include(CMakeAddFortranSubdirectory) cmake_add_fortran_subdirectory(src NO_EXTERNAL_INSTALL PROJECT EMSoftLib # project name in toplevel CMakeLists.txt in lapack LIBRARIES EMSoftLib # target libraries created LINK_LIBRARIES blas lapack # link interface libraries LINK_LIBS EMSoftLib blas lapack ) include(FortranCInterface) FortranCInterface_HEADER(EMsoftLib_Mangling.h MACRO_NAMESPACE "EMSOFTLIB_") So far so good. In the FORTRAN code we have the following declaration for a subroutine we want to use from the "C" side of things: subroutine SingleEBSDPattern(ipar, fpar, EBSDpattern, quats, accum_e, mLPNH, mLPSH) bind(c, name='SingleEBSDPattern') In order to access that function we created the following header file: #include "EMsoftLib_Mangling.h" #ifdef __cplusplus extern "C" { #endif void EMSOFTLIB_GLOBAL(SingleEBSDPattern, SINGLEEBSDPATTERN) (size_t* ipar, float* fpar, float* EBSDpattern, float* quats, float* accum_e, float* mLPNH, float* mLPSH); #ifdef __cplusplus } #endif and we call the function from our C code like the following: SingleEBSDPattern_(ipar, fpar, ebsdPattern, quats, accum_e, mLPNH, mLPSH); When we compile we get the following linker error: MintDevVM:Build mdg$ make [ 40%] Built target EMSoftLib Scanning dependencies of target SingleEBSDPattern [ 41%] Building CXX object src/CMakeFiles/SingleEBSDPattern.dir/SingleEBSDPattern.cpp.o [ 42%] Linking CXX executable ../Bin/SingleEBSDPattern Undefined symbols for architecture x86_64: "_SingleEBSDPattern_", referenced from: _main in SingleEBSDPattern.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [Bin/SingleEBSDPattern] Error 1 make[1]: *** [src/CMakeFiles/SingleEBSDPattern.dir/all] Error 2 make: *** [all] Error 2 We can not seem to find any good examples of trying this sort of C->FORTRAN interfacing with CMake besides http://www.kitware.com/blog/home/post/231 We are using gfortran 5.3 on OS X 10.10.5 with Xcode 7.2 tools. Any insights would be most appreciated. __________________________________________________ Mike Jackson mike.jack...@bluequartz.net BlueQuartz Software www.bluequartz.net Principal Software Engineer Dayton, Ohio
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake