Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05-inheritance linking error in VS2015 #10

Closed
simbaforrest opened this issue Feb 27, 2017 · 6 comments
Closed

05-inheritance linking error in VS2015 #10

simbaforrest opened this issue Feb 27, 2017 · 6 comments

Comments

@simbaforrest
Copy link

simbaforrest commented Feb 27, 2017

Thanks for the project first.

I can compile and run all other example except for 05-inheritance on VS 2015 with Boost.Python 2.7 x64, which gave me the following linking error:

1>inheritance.obj : error LNK2019: unresolved external symbol "class Base const volatile * __cdecl boost::get_pointer<class Base const volatile >(class Base const volatile *)" (??$get_pointer@$$CDVBase@@@boost@@YAPEDVBase@@PEDV1@@Z) referenced in function "public: static struct _object * __cdecl boost::python::objects::make_instance_impl<class Base,struct boost::python::objects::pointer_holder<class std::auto_ptr<class Base>,class Base>,struct boost::python::objects::make_ptr_instance<class Base,struct boost::python::objects::pointer_holder<class std::auto_ptr<class Base>,class Base> > >::execute<class std::auto_ptr<class Base> >(class std::auto_ptr<class Base> &)" (??$execute@V?$auto_ptr@VBase@@@std@@@?$make_instance_impl@VBase@@U?$pointer_holder@V?$auto_ptr@VBase@@@std@@VBase@@@objects@python@boost@@U?$make_ptr_instance@VBase@@U?$pointer_holder@V?$auto_ptr@VBase@@@std@@VBase@@@objects@python@boost@@@345@@objects@python@boost@@SAPEAU_object@@AEAV?$auto_ptr@VBase@@@std@@@Z)

Based on this discussion, I was able to fix the problem by adding the following code to inheritance.cpp. Not sure whether this should be counted as a bug of this project, but I guess it might help others if they also found this issue.

namespace boost
{
	template <>
	Base const volatile * get_pointer<class Base const volatile >(
		class Base const volatile *c)
	{
		return c;
	}
}
@Achimh3011
Copy link
Member

Do you want to open a PR? I never tried to compile the code on Windows, but it'd be nice to have that platform supported as well.

@mkulagowski
Copy link

mkulagowski commented Sep 3, 2017

I know it's been a couple of months now, but I need to use Boost::python and tried to crack it with a help of Your code. After few days and boost-headaches I can say, that I successfully ran Your code on:
-Win 10 x64
-Python 3.6 x64
-Boost 1.65
-VS Enterprise 2017 v.15.2 (compiler msvc-14.1)
-CMake 3.9.1

I built all of them, but checked only 1,2,3 & 5.

@Achimh3011
Copy link
Member

Hi, was the aforementioned patch included or did it work without?

@mkulagowski
Copy link

mkulagowski commented Sep 3, 2017

It worked without but I had to:

  • build Boost myself, to make it work with my python version (not sure how it works with boost::python for python 2.7).
  • make change in CMakeLists to look for python (not python3).
  • make changes in CMake (FindBoost.cmake) to actually recognize Boost 1.65
  • change linker settings in VS to look for boost_python3*.dll instead of boost_python*.dll one.
  • move created *.pyd file next to the *.py file for it to work, but that is normal as far as I recall.

Yet all of these problems are related to Boost and CMake, not Your code ;)

@Achimh3011
Copy link
Member

I close the issue now. I'd still accept an PR if anyone had one...

@ruoxu233
Copy link

It worked without but I had to:

  • build Boost myself, to make it work with my python version (not sure how it works with boost::python for python 2.7).
  • make change in CMakeLists to look for python (not python3).
  • make changes in CMake (FindBoost.cmake) to actually recognize Boost 1.65
  • change linker settings in VS to look for boost_python3*.dll instead of boost_python*.dll one.
  • move created *.pyd file next to the *.py file for it to work, but that is normal as far as I recall.

Yet all of these problems are related to Boost and CMake, not Your code ;)

build Boost _python need careful, othervise will happen Link error like this:
1>boost_python39-vc142-mt-gd-x64-1_75.lib(pickle_support.obj): error LNK2001: unresolved external symbol __imp__Py_Dealloc
1>boost_python39-vc142-mt-gd-x64-1_75.lib(function.obj) : error LNK2019: unresolved external symbol __imp__Py_NewReference referenced in function _PyObject_INIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants