On 6/2/2012 8:26 AM, Shipeng Shu wrote:
Hi, I'm writing a C++ code but I want to also use some of the Fortran code that has been previously tested. And I'm new to cmake.My CmakeList.txt looks like this: PROJECT (IRR CXX Fortran) ENABLE_LANGUAGE(Fortran) SET(SRC_LIST demo.cpp global.cpp global_variables.cpp init_config.cpp input.cpp irr.cpp output.cpp ./src_tools/rng.cpp global.h global_variables.h init_config.h input.h irr.h ./src_tools/nr3.h output.h ./src_tools/rng.h ./src_tools/vector3.h ./src_tools/tool_output.h ./src_tools/tools.cpp ./src_tools/tools.h ./src_tools/timer.h ./src_tools/timer.cpp ./src_tools/difconnector.h) SET(SRC_FORTRAN_LIST ./src_tools/difquat.f ./src_tools/fourn.f) SET(CMAKE_CXX_FLAGS "-O3 -ip") ADD_EXECUTABLE(irr.x ${SRC_LIST} ${SRC_FORTRAN_LIST}) But the compiler gives me error information like these: CMakeFiles/irr.x.dir/src_tools/difquat.o: In function `difquat_': /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xc4): undefined reference to `for_write_seq_lis' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xef): undefined reference to `for_write_seq_lis_xmit' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x159): undefined reference to `for_open' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x1cc): undefined reference to `for_open' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x214): undefined reference to `for_read_seq_lis' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x24e): undefined reference to `for_close' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xb94): undefined reference to `for_write_seq_fmt' /home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xbb9): undefined reference to `for_write_seq_fmt_xmit' It seems to me that I need some Fortran library, but I think Cmake should have include them since I enabled Fortran. I'm confused about it. Could you please tell me why I get all these things? How should I modify the CmakeList.txt to get things work?
Looks like you are not linking all the libraries you are using or you left source code out of the project. Where does this symbol come from: for_write_seq_fmt_xmit
-Bill -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
