0
votes

I'm new to VS 8 and C++ in Windows in general. I'm having a strange issue when I attempt to compile a Python extension in VC 8 in two different projects (one was a very simple dummy test project and the other is a fairly large project which I want to add extensions to).

I provide the same include/library directories required for Boost.Python to both projects. They are as follows:

Include Directories:

  • C:\boost-python\boost_1_46_1
  • C:\Python27\include

Library Directories:

  • C:\boost-python\boost_1_46_1\stage\lib
  • C:\Python27\libs

The dummy project compiles and works without issue, the other project seems to be missing a specific library. VS 8 gives the following error message:

Error   3   fatal error LNK1104: cannot open file 'libboost_python-vc80-mt-gdp-1_46_1.lib'  

'libboost_python-vc80-mt-gdp-1_46_1.lib' was not made when I built the boost libraries.

I remember the dummy project complained about missing 'libboost_python-vc80-mt-gd-1_46_1.lib' when I did not include the 'C:\boost-python\boost_1_46_1\stage\lib'. But after I supplied that library directory, it compiled without issue. 'libboost_python-vc80-mt-gd-1_46_1.lib' does exist in that directory.

So the I'm confused why my other project is looking for gdp instead of gd like my dummy project. The python specific portion of the code is the same in both projects.

This was the dummy code I was testing:

#include <boost/python.hpp>
#include <boost/random.hpp>
#include <boost/random/normal_distribution.hpp>

using namespace boost::python;

boost::mt19937 gen;

struct World
{
    std::string msg;
    double mypi;

    World(std::string msg): msg(msg) {
        gen.seed(std::time(0));
    } // added constructor
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    double get() const { return mypi; }
    void setter(double mypi) { this->mypi = mypi; }

    double getgaussrand() {
        boost::normal_distribution<> nd(0.0, 1.0);
        boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(gen, nd);
        return var_nor();
    }

};

BOOST_PYTHON_MODULE(test_vs_proj_dll)
{
    class_<World>("World", init<std::string>())
        .def("greet", &World::greet)
        .def("set", &World::set)
        .def("getgaussrand", &World::getgaussrand)
        .def_readonly("msg",  &World::msg)
        .def_readwrite("mypi", &World::mypi)
        .add_property("rovalue", &World::get)
        .add_property("value", &World::get, &World::setter)
    ;
}
1
How do you add .lib files in Visual Studio 8? I have only used VS2005, where you type in the name of every .lib file you are using, so a problem like this should be solved checking that the names of the files are spelled correctly. How is it done in VS8? - Jong Bor Lee
I just added the library directories. Also, by VS 8 I mean visual studio 8.0 whic his VS2005. - Christopher Dorian
What do you have in Configuration Properties -> Linker -> Input -> Additional Dependencies? (like this screenshot: tenouk.com/ModuleM_files/image002.png) - Jong Bor Lee

1 Answers

0
votes

Based on the boost library naming it picked for itself, it sounds like your large project builds with different arguments using the STLPort library rather than your compiler's native one and your dummy project does not.

-gdp
  • g - using debug versions of the standard and runtime support libraries.
  • d - building a debug version of your code.
  • p - using the STLPort standard library rather than the default one supplied with your compiler.

The Library Naming section of the Getting Started on Windows Boost guide has more information.