| Store | Cart

[C++-sig] LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and numpy3 libraries on Windows

From: Øystein Skotheim <oyst...@zividlabs.com>
Mon, 22 May 2017 19:05:41 +0000
I have downloaded and built Boost 1.64 on Windows by using the following command:

b2 --build-type=complete address-model=64 toolset=msvc stage
I added a user-config.jam file in my home directory to tell Boost where to find Python 3:

using python : 3.6 : c:\\anaconda3\\python ;
I am then trying to compile a small test project using boost::python and boost::numpy:

	#include <boost/python.hpp>
	#include <boost/python/numpy.hpp>

	namespace bp = boost::python;
	namespace np = boost::python::numpy;

	np::ndarray test_make_zeros(int rows, int cols)
	{
		return np::zeros(bp::make_tuple(rows, cols), np::dtype::get_builtin<float>());  
	}

	BOOST_PYTHON_MODULE(test_boost_python)
	{
		np::initialize();
		bp::def("test_make_zeros", test_make_zeros);
	}

I am using the following CMakeLists.txt file:

	cmake_minimum_required(VERSION 3.8)
	project(test_boost_python)

	set(BOOST_ROOT "C:/Boost-1.64")
	set(Boost_ADDITIONAL_VERSIONS 1.64)

	find_package(PythonLibs 3.6 REQUIRED)
	include_directories(${PYTHON_INCLUDE_DIRS})

	find_package(Boost REQUIRED COMPONENTS python3 numpy3)
	include_directories(${Boost_INCLUDE_DIRS})
	link_directories(${Boost_LIBRARY_DIRS})

	add_library(test_boost_python SHARED test_boost_python.cpp)
	set_target_properties(test_boost_python PROPERTIES PREFIX "" SUFFIX ".pyd")
	set_target_properties(test_boost_python PROPERTIES DEFINE_SYMBOL "BOOST_ALL_NO_LIB")
	target_link_libraries(test_boost_python ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})

My boost::python library is given the name boost_python3-vc140-mt-1_64.lib and boost::numpy ends up as boost_numpy3-vc140-mt-1_64.lib when linking against Python 3.6.

I had to turn on BOOST_ALL_NO_LIB. If not, the compiler looks for boost_python-vc140-mt-1_64.lib boost_numpy-vc140-mt-1_64.lib (which is under the wrong name, with a missing number 3 after the library names - Is this a bug on Windows?)

For my test project, I now get the following linking error:

	test_boost_python.obj : error LNK2019: unresolved external symbol "class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::get_float_dtype<32>(void)" (??$g...@$0CA@@det...@numpy@pyt...@boost@@YA?A...@123@XZ) referenced in function "public: static class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::builtin_dtype<float,0>::get(void)" (?...@?$builtin_dtype@M$0A@@det...@numpy@pyt...@boost@@SA?A...@345@XZ)

What may be the reason for this missing symbol and how should I go about to fix it?

-Øystein
_______________________________________________
Cplusplus-sig mailing list
Cplu...@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Recent Messages in this Thread
Øystein Skotheim May 22, 2017 07:05 pm