Jump to content
  • Advertisement
Sign in to follow this  
telmarc

boost::python troubles

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i've been playing with boost::python and for the most part its working great. But when i try to expose a class with a virtual function, everything falls apart. I get an "unresolved external symbol" when i use get_override(). I'm linking with boost_python_debug.lib so I can't figure out why linker can't find it. Here's the code that's breaking and the specific error i'm getting.
#include <string>
#include <iostream>

#include <boost/python.hpp>
using namespace boost::python;


class MyClass
{
public:
	MyClass() {}
	virtual ~MyClass() {}

	virtual void Print() = 0;
};

struct MyClassWrapper : MyClass, wrapper<MyClass>
{
	void Print()
	{
		this->get_override("Print")();
	}
};


BOOST_PYTHON_MODULE(pythonTest)
{
	class_<MyClassWrapper, boost::noncopyable>("MyClass")
		.def("Print", pure_virtual(&MyClass::Print));
}

the error message:
error LNK2019: unresolved external symbol "__declspec(dllimport) protected: class boost::python::override __thiscall boost::python::detail::wrapper_base::get_override(char const *,struct _typeobject *)const " (__imp_?get_override@wrapper_base@detail@python@boost@@IBE?AVoverride@34@PBDPAU_typeobject@@@Z) referenced in function "protected: class boost::python::override __thiscall boost::python::wrapper<class MyClass>::get_override(char const *)const " (?get_override@?$wrapper@VMyClass@@@python@boost@@IBE?AVoverride@23@PBD@Z)

It acts like i'm not linking the boost::python lib, but i am. What else could I be missing? Oh, and i'm trying to build this with visual studio.net 2003. somebody save my sanity

Share this post


Link to post
Share on other sites
Advertisement
yes, i did enable RTTI.

I'm using 1.32.0 and i used the included vs project to build the boost::python library. I would imagine the vs proj would produce the same result as bjam, but should i rebuild the library with bjam anyway?

and for the sake of being thorough, here's the compiler and linker commandline my project is using (copied from the build log).

Creating temporary file "d:\projects\pythonTest\Debug\RSP000056.rsp" with contents
[
/Od /I "D:\boost\boost_1_32_0" /I "D:\Python24\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PYTHONTEST_EXPORTS" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS /GR /Yu"stdafx.h" /Fp"Debug/pythonTest.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /Zi /TP
pythonTest.cpp
]
Creating command line "cl.exe @d:\projects\pythonTest\Debug\RSP000056.rsp /nologo"
Creating temporary file "d:\projects\pythonTest\Debug\RSP000057.rsp" with contents
[
/OUT:"Debug/pythonTest.dll" /INCREMENTAL:NO /NOLOGO /LIBPATH:"D:\Python24\libs" /DLL /DEBUG /PDB:"Debug/pythonTest.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"Debug/pythonTest.lib" /MACHINE:IX86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\boost\boost_1_32_0\libs\python\build\bin-stage\boost_python_debug.lib"
Debug\stdafx.obj
Debug\pythonTest.obj
]
Creating command line "link.exe @d:\projects\pythonTest\Debug\RSP000057.rsp"

Share this post


Link to post
Share on other sites
Ok, I got it to build. All it took was rebuilding the library using bjam. Apparently the visual studio project is out of date and/or broken. I suppose the fact it was a vc6 project should have tipped me off.

Thanks for the help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!