Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:47:10+00:00 2026-06-05T06:47:10+00:00

I built a DLL in VS2010 with boost::python to export some function to a

  • 0

I built a DLL in VS2010 with boost::python to export some function to a python module:

myDLL.cpp:

std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }

BOOST_PYTHON_MODULE(getting_started1)
{
    // Add regular functions to the module.
    def("greet", greet);
    def("square", square);
}

Up to here, everything compiles just fine. I then get the myDLL.dll and myDLL.lib file in c:\myDLL\Debug.

According to boost doc (http://wiki.python.org/moin/boost.python/SimpleExample), I need to add this to PYTHONPATH, so I added c:\myDLL\Debug to it:
PYTHONPATH:
C:\Python27;c:\myDLL\Debug;

then, from my .py file, I try to import it:

import getting_started1
print getting_started1.greet()
number = 11
print number, '*', number, '=', getting_started1.square(number)

I have also tried from myDLL import getting_started1, and from getting_started1 import *, and all possible combinations of sorts.

Can anyone tell me how am I supposed to call my module? Thanks

EDIT:
According to cgohlke, there should be a getting_started1.pyd somewhere in my PYTHONPATH when I compile in VS? This file is inexistant… Do I have to set somethign different in VS2010? I have a default win32 DLL project.
But the boost doc says ” If we build this shared library and put it on our PYTHONPATH”, isn’t a shared library on windows a DLL? ergo, the DLL should be in the PYTHONPATH?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:47:12+00:00Added an answer on June 5, 2026 at 6:47 am

    The standard, portable way to build Python extensions is via distutils. However, Visual Studio 2010 is not a supported compiler for Python 2.7. The following setup.py works for me with Visual Studio 2008 and boost_1_48_0. The build command is python setup.py build_ext --inplace.

    # setup.py
    from distutils.core import setup
    from distutils.extension import Extension
    setup(name="getting_started1",
        ext_modules=[
            Extension("getting_started1", ["getting_started1.cpp"],
            include_dirs=['boost_1_48_0'],
            libraries = ['boost_python-vc90-mt-1_48'],
            extra_compile_args=['/EHsc', '/FD', '/DBOOST_ALL_DYN_LINK=1']
            )
        ])
    

    For your Visual Studio 2010 project, try to change the linker output file to getting_started1.pyd instead of myDLL.dll.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VC++ project in VS2010 that is linking to some dll's built
The debug configuration of my app is built against: PYTHON25_D.DLL MSVCR80D.DLL We use Python
I have a project that comprises pre-build Dll modules, built some time in the
I have a simple .NET dll built with VS2010 C# that exposes 2 static
I have built a dll with VS2010 targeted for framework 4.0. When I try
I created a new c++ DLL project in VS2010 that exposes 1 function #include
Given: a dll which has been built in directory A a debugging PC with
I've built app using wmp.dll which is Windows System File in my XP machine.
I created a DLL project and successfully built it. I then tried to use
Background: I built an installer for my app, and all my dll's and content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.