Skip to content

Commit

Permalink
cmake: link pycsdiff with PythonX::Module
Browse files Browse the repository at this point in the history
... to fix the following build error on macOS:
```
[ 86%] Linking CXX shared library pycsdiff_py3/pycsdiff.dylib
ld: Undefined symbols:
  _PyUnicode_FromStringAndSize, referenced from:
      boost::python::detail::caller_arity<2u>::impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), boost::python::default_call_policies, boost::mpl::vector3<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>>::operator()(_object*, _object*) in pycsdiff.cc.o
      boost::python::objects::caller_py_function_impl<boost::python::detail::caller<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(), boost::python::default_call_policies, boost::mpl::vector1<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>::operator()(_object*, _object*) in pycsdiff.cc.o
  _PyUnicode_Type, referenced from:
      boost::python::detail::converter_target_type<boost::python::to_python_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>>::get_pytype() in pycsdiff.cc.o
  __Py_Dealloc, referenced from:
      boost::python::api::slice_nil::~slice_nil() in pycsdiff.cc.o
      void boost::python::def<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)) in pycsdiff.cc.o
      void boost::python::def<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)()>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)()) in pycsdiff.cc.o
      boost::python::api::object::~object() in pycsdiff.cc.o
  __Py_NoneStruct, referenced from:
      __GLOBAL__sub_I_pycsdiff.cc in pycsdiff.cc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
  • Loading branch information
lzaoral committed Dec 10, 2023
1 parent a2857ce commit 9f94669
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with csdiff. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.15)
project(csdiff CXX)
enable_testing()

Expand Down
5 changes: 2 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ macro(build_pycsdiff version)
"The pycsdiff module will be built!")

add_library(pycsdiff_py${version} SHARED pycsdiff.cc)
target_include_directories(pycsdiff_py${version} SYSTEM
PRIVATE ${Python${version}_INCLUDE_DIRS})
target_link_libraries(pycsdiff_py${version}
PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY})
PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY}
Python${version}::Module)

# set correct name so that `python -c 'import pycsdiff' works`
set_target_properties(pycsdiff_py${version} PROPERTIES
Expand Down

0 comments on commit 9f94669

Please sign in to comment.