2

I download boost1.55 zip from official website and then build with command bootstrap and b2. And I tried example code, but it has a link error.

1>LINK : fatal error LNK1104: cannot open file 'libboost_python-vc120-mt-gd-1_55.lib'

Below is what I did.

  1. New project win32 Console application, DLL empty.
  2. Add include path, library path in VC++ DIRECTORIES like the below.

    INCLUDE DIRECTORIES: C:\boost\boost_1_55_0;C:\Python27\include 
    LIBRARY DIRECTORIES: C:\boost\boost_1_55_0\libs;C:\Python27\libs
    

.

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

struct World
{
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    std::string msg;
};


BOOST_PYTHON_MODULE(hello)
{
    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set);
}

Edit

If i add the library directory, C:\boost_1_55_0\stage\liblike an answer below, it make many errors happen, around 200 below is just the part of errors.

1>------ Build started: Project: hello, Configuration: Debug Win32 ------ 1> hello.cpp 1>c:\python27\include\pymath.h(22): warning C4273: 'round' : inconsistent dll linkage 1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\math.h(516) : see previous definition of 'round' 1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xtgmath.h(190): warning C4273: '_hypot' : inconsistent dll linkage 1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\math.h(538) : see previous definition of '_hypot' 1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xtgmath.h(206): warning C4273: 'round' : inconsistent dll linkage 1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\math.h(516) : see previous definition of 'round' 1>c:\boost_1_55_0\boost\python\opaque_pointer_converter.hpp : warning C4819: The file contains a character that cannot be represented in the current code page (949). Save the file in Unicode format to prevent data loss 1>c:\boost_1_55_0\boost\python\return_opaque_pointer.hpp : warning C4819: The file contains a character that cannot be represented in the current code page (949). Save the file in Unicode format to prevent data loss 1> Creating library C:\Users\User\documents\visual studio 2013\Projects\hello\Debug\hello.lib and object C:\Users\User\documents\visual studio 2013\Projects\hello\Debug\hello.exp 1>hello.obj : error LNK2019: unresolved external symbol __imp__PyString_FromStringAndSize referenced in function "public: struct _object * __thiscall boost::python::to_python_value,class std::allocator > const &>::operator()(class std::basic_string,class std::allocator > const &)const " (??R?$to_python_value@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@python@boost@@QBEPAU_object@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 1>libboost_python-vc120-mt-gd-1_55.lib(builtin_converters.obj) : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize 1>libboost_python-vc120-mt-gd-1_55.lib(str.obj) : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize 1>libboost_python-vc120-mt-gd-1_55.lib(function_doc_signature.obj) : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize 1>libboost_python-vc120-mt-gd-1_55.lib(list.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(tuple.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(function_doc_signature.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(object_protocol.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(pickle_support.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(dict.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(str.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(from_python.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(function.obj) : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>libboost_python-vc120-mt-gd-1_55.lib(module.obj) : error LNK2001:

2
  • Does libboost_python-vc120-mt-gd-1_55.lib exist in C:\boost\boost_1_55_0\libs? Commented Oct 19, 2014 at 21:21
  • It exists in C:\boost_1_55_0\stage\lib And C:\boost_1_55_0\bin.v2\libs\python\build\msvc-12.0\debug\link-static\threading-multi Commented Oct 21, 2014 at 7:55

1 Answer 1

2

The "LIBRARY DIRECTORY" should reference C:\boost_1_55_0\stage\lib instead of C:\boost\boost_1_55_0\libs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.