【发布时间】:2014-03-03 03:24:36
【问题描述】:
我可以在没有 CMake 的情况下使用手写的 Makefile 来做到这一点,如下所示:
g++ $(CXSCINC) -c -fPIC cellComplex_extern.cpp -o cellComplex_extern.o
g++ $(CXSCINC) -shared -Wl -o cellComplex_lib.so cellComplex_extern.o $(CXSCLIB) -lcxsc
这让我共享库cellComplex_lib.so,然后被ctypes 拾取为动态链接库(lib = ctypes.cdll.LoadLibrary('./cellComplex_lib.so')供以后使用。
我的项目已作为构建系统迁移到 CMake,我希望模拟上面的 Makefile 的功能。
到目前为止,我已经发现了用于 CMakeLists.txt 的 add_library() 命令,但从未建立到 CXSC 库的链接(正如我在 cmake 之后运行 make 时出现的可怕抱怨所证明的那样。
如何告诉 CMake 使用第三方库 CXSC 构建 cellComplex_lib?
-- 不工作CMakeLists.txt--
add_library(include/python/cellComplex_extern OBJECT
include/python/cellComplex_extern.cpp ${all_headers})
add_library(include/python/cellComplex_lib SHARED
include/python/cellComplex_extern)
target_link_libraries(include/python/cellComplex_lib ${CXSC_LIB_DIR}/libcxsc.a)
运行cmake后make的结果:
.
.
.
[ 75%] Built target include/python/cellComplex_extern
Linking CXX shared library libinclude/python/cellComplex_lib.dylib
ld: can't open output file for writing: libinclude/python/cellComplex_lib.dylib, errno=2 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libinclude/python/cellComplex_lib.dylib] Error 1
make[1]: *** [CMakeFiles/include/python/cellComplex_lib.dir/all] Error 2
make: *** [all] Error 2
【问题讨论】:
-
您现在好像遇到了路径问题。还是正在使用该库?
标签: cmake