Skip to content

05-inheritance linking error in VS2015 #10

Closed

Description

@simbaforrest

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;
	}
}

Activity

  1. Achimh3011 commented on Mar 6, 2017

    @Achimh3011
    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.

  2. mkulagowski commented on Sep 3, 2017

    @mkulagowski

    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.

  3. Achimh3011 commented on Sep 3, 2017

    @Achimh3011
    Member

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

  4. mkulagowski commented on Sep 3, 2017

    @mkulagowski

    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 ;)

  5. Achimh3011 commented on Jun 19, 2018

    @Achimh3011
    Member

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

  6. ruoxu233 commented on Jan 14, 2023

    @ruoxu233

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions