0
나는 CMakeLists.txt 파일에 다음 코드가있다 : I 출력을 볼 때FindSWIG.cmake 수없는
# find Python
find_package(PythonInterp)
# find SWIG
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH})
message(STATUS "PYTHON_INCLUDE_PATH: ${PYTHON_INCLUDE_PATH}")
message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core)
SET_SOURCE_FILES_PROPERTIES(swig/core.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties(swig/core.i SWIG_FLAGS "-includeall;-c++;-shadow")
swig_add_module(core python swig/core.i core/foo.cpp)
swig_link_libraries(core hybrida_core ${PYTHON_LIBRARIES})
이 나에게 제공합니다
-- Found PythonInterp: /Users/aaragon/.virtualenvs/pydev/bin/python (found version "3.4.1")
-- PYTHON_EXECUTABLE: /Users/aaragon/.virtualenvs/pydev/bin/python
-- Python version: 3.4.1
-- Found SWIG: /usr/local/bin/swig (found version "3.0.3")
-- Found PythonLibs: /usr/lib/libpython3.4.dylib (found version "2.7.6")
-- PYTHON_INCLUDE_PATH: /System/Library/Frameworks/Python.framework/Headers
-- PYTHON_LIBRARIES: /usr/lib/libpython3.4.dylib
따라서 버전 2.7.6을 발견 했으므로 PythonLibs
에 대한 문제가 발견되었습니다. 이것은 나중에 오류를 연결하는 톤 결과 :
Linking CXX shared module _core.so
Undefined symbols for architecture x86_64:
"_PyClass_Type", referenced from:
SwigPyClientData_New(_object*) in corePYTHON_wrap.cxx.o
"_PyInstance_NewRaw", referenced from:
SWIG_Python_NewShadowInstance(SwigPyClientData*, _object*) in corePYTHON_wrap.cxx.o
"_PyInstance_Type", referenced from:
SWIG_Python_GetSwigThis(_object*) in corePYTHON_wrap.cxx.o
"_PyInt_AsLong", referenced from:
SWIG_AsVal_long(_object*, long*) in corePYTHON_wrap.cxx.o
SWIG_AsVal_unsigned_SS_long(_object*, unsigned long*) in corePYTHON_wrap.cxx.o
SWIG_AsVal_double(_object*, double*) in corePYTHON_wrap.cxx.o
"_PyInt_FromLong", referenced from:
SWIG_From_int(int) in corePYTHON_wrap.cxx.o
"_PyString_AsString", referenced from:
SWIG_Python_str_AsChar(_object*) in corePYTHON_wrap.cxx.o
"_PyString_AsStringAndSize", referenced from:
SWIG_AsCharPtrAndSize(_object*, char**, unsigned long*, int*) in corePYTHON_wrap.cxx.o
"_PyString_ConcatAndDel", referenced from:
SwigPyObject_repr(SwigPyObject*) in corePYTHON_wrap.cxx.o
swig_varlink_str(swig_varlinkobject*) in corePYTHON_wrap.cxx.o
"_PyString_Format", referenced from:
SwigPyObject_format(char const*, SwigPyObject*) in corePYTHON_wrap.cxx.o
"_PyString_FromFormat", referenced from:
SwigPyObject_repr(SwigPyObject*) in corePYTHON_wrap.cxx.o
SwigPyPacked_repr(SwigPyPacked*) in corePYTHON_wrap.cxx.o
SwigPyPacked_str(SwigPyPacked*) in corePYTHON_wrap.cxx.o
"_PyString_FromString", referenced from:
SWIG_Python_str_FromChar(char const*) in corePYTHON_wrap.cxx.o
swig_varlink_repr(swig_varlinkobject*) in corePYTHON_wrap.cxx.o
swig_varlink_str(swig_varlinkobject*) in corePYTHON_wrap.cxx.o
"_PyString_FromStringAndSize", referenced from:
SWIG_FromCharPtrAndSize(char const*, unsigned long) in corePYTHON_wrap.cxx.o
"_Py_InitModule4_64", referenced from:
_init_core in corePYTHON_wrap.cxx.o
SWIG_Python_SetModule(swig_module_info*) in corePYTHON_wrap.cxx.o
"__PyInstance_Lookup", referenced from:
SWIG_Python_GetSwigThis(_object*) in corePYTHON_wrap.cxx.o
ld: symbol(s) not found for architecture x86_64
만약 내가 다음과 같은 변수 하드 코드 :
set (PYTHON_INCLUDE_DIR /Library/Frameworks/Python.framework/Versions/3.4/Headers)
그럼 내가 제대로 컴파일 및 링크 할 수 있어요. cmake가 파이썬을위한 올바른 헤더 파일/라이브러리 조합을 결정할 수 없습니까?