Boost logo

Boost :

From: ron_clarke_at_[hidden]
Date: 2000-10-31 18:51:15


I tried to use py_cpp for the first time today (using the contents
of "py_cpp_20001031.zip"). A few bumps, but overall things are clean
except for this link error from MSVC6 (running under Windows2000):

main.obj : error LNK2001: unresolved external symbol "class
bkdo::BKDataObj & __cdecl from_python(struct _object *,struct
py::Type<class bkdo::BKDataObj &>)" (?
from_python@@YAAAVBKDataObj_at_bkdo@@PAU_object@@U?
$Type_at_AAVBKDataObj@bkdo@@@py@@@Z)
Debug/BKDO.dll : fatal error LNK1120: 1 unresolved externals

Here is my code from "main.cpp":
#pragma warning(disable : 4541) //dynamic_cast used on polymorphic
type

#include <class_wrapper.h>
#include "BKDataObj.h"

void dobkdo_init();

// Python requires an exported function called init<module-name> in
every
// extension module. This is where we build the module contents.
extern "C"
#ifdef WIN32
__declspec(dllexport)
#endif
void initbkdo()
{
        dobkdo_init();
}

void dobkdo_init()
{
    try
    {
       // create an object representing this extension module
       py::Module bkdo("bkdo");
       // Create the Python type object for our extension class
       py::ClassWrapper<bkdo::BKDataObj> dataobj_class
(bkdo, "BKDataObj");
       // Add the __init__ function
       dataobj_class.def(py::Constructor<>());
       // Add a regular member function
       dataobj_class.def(&bkdo::BKDataObj::WinBeep, "WinBeep");
       // Add a regular function to the module
       //bkdo.def(bkdo::length, "length");
    }
    catch(...)
    {
       py::handle_exception(); // Deal with the exception for
Python
    }
}

// Win32 DLL boilerplate
#if defined(WIN32)
#include <windows.h>
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
{
    return 1;
}
#endif // WIN32

//(end code)//

'bkdo' is a namespace; class BKDataObj is currently a simple class
that does nothing (keep it simple at first). I've been through my
code and the py_cpp code and cannot determine the reason the linker
is complaining about 'from_python'. I have included these source
files in my MSVC project:
extclass.cpp
functions.cpp
init_function.cpp
module.cpp
newtypes.cpp
objects.cpp
py.cpp
subclass.cpp
     
I also successfully built these files as a separate, static library
and tried it that way, just in case. Nothing different; still get the
same linker error. What am I missing?

Thanks for taking the time...

Ron Clarke
ron_clarke_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk