[python] Linker error when initializing numpy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[python] Linker error when initializing numpy

Boost - Users mailing list
Hi all,

I have the latest boost from the master branch and built everything including python. I can see that two python related libs were built:

libboost_python3-vc141-mt-gd-x64-1_66.lib
libboost_numpy3-vc141-mt-gd-x64-1_66.lib

For compiling python I use vcpkg and it's generating python3_d.lib for debug and python3.lib for release.


The cpp code I like to compile is:

#include <iostream>

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>


namespace p = boost::python;
namespace np = boost::python::numpy;

int main()
{
    Py_Initialize();
    np::initialize();

    return 0;
}


A few issues:

1) linker is looking for "boost_python3-vc141-mt-gd-x64-1_66.lib" but I got "libboost_python3-vc141-mt-gd-x64-1_66.lib"

Please tell me how to fix that. For now I just copied the libboost* files  and renamed them.

2) Linker error:

"__declspec(dllimport) void __cdecl boost::python::numpy::initialize(bool)"

How can I resolve that?

Thanks,
Christian


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
How are you compiling the test progam? Did you set up a test solution? Are you compiling it from command line with cl? Are you trying to use cmake?

Why did you build boost with vcpkg? IIRC, vcpkg/cmake has own conventions; the libraries in the official boost windows distribution do not have 'lib' prefix.

In any case, set up a project in the IDE and adjust linker search paths and libraries to link against (Linker -> Input -> Additional dependencies) in the project properties tab.

________________________________________
From: Boost-users <[hidden email]> on behalf of Christian Henning via Boost-users <[hidden email]>
Sent: Thursday, November 16, 2017 9:16:36 PM
To: [hidden email]
Cc: Christian Henning
Subject: [Boost-users] [python] Linker error when initializing numpy

Hi all,

I have the latest boost from the master branch and built everything including python. I can see that two python related libs were built:

libboost_python3-vc141-mt-gd-x64-1_66.lib
libboost_numpy3-vc141-mt-gd-x64-1_66.lib

For compiling python I use vcpkg and it's generating python3_d.lib for debug and python3.lib for release.


The cpp code I like to compile is:

#include <iostream>

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>


namespace p = boost::python;
namespace np = boost::python::numpy;

int main()
{
    Py_Initialize();
    np::initialize();

    return 0;
}


A few issues:

1) linker is looking for "boost_python3-vc141-mt-gd-x64-1_66.lib" but I got "libboost_python3-vc141-mt-gd-x64-1_66.lib"

Please tell me how to fix that. For now I just copied the libboost* files  and renamed them.

2) Linker error:

"__declspec(dllimport) void __cdecl boost::python::numpy::initialize(bool)"

How can I resolve that?

Thanks,
Christian

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
Hi all,

OK, it seems that I have lost some of my boost zen. I remember now that "libboost*.lib" are the static libs and that "boost*.lib" are dynamic variant. I have built both and the linking now works. It seems that linking to static boost libs is not supported on Windows with Visual Studio 2017. Not sure why?

Regards,
Christian


On Fri, Nov 17, 2017 at 1:01 AM, Stian Zeljko Vrba <[hidden email]> wrote:
How are you compiling the test progam? Did you set up a test solution? Are you compiling it from command line with cl? Are you trying to use cmake?

Why did you build boost with vcpkg? IIRC, vcpkg/cmake has own conventions; the libraries in the official boost windows distribution do not have 'lib' prefix.

In any case, set up a project in the IDE and adjust linker search paths and libraries to link against (Linker -> Input -> Additional dependencies) in the project properties tab.

________________________________________
From: Boost-users <[hidden email]> on behalf of Christian Henning via Boost-users <[hidden email]>
Sent: Thursday, November 16, 2017 9:16:36 PM
To: [hidden email]
Cc: Christian Henning
Subject: [Boost-users] [python] Linker error when initializing numpy

Hi all,

I have the latest boost from the master branch and built everything including python. I can see that two python related libs were built:

libboost_python3-vc141-mt-gd-x64-1_66.lib
libboost_numpy3-vc141-mt-gd-x64-1_66.lib

For compiling python I use vcpkg and it's generating python3_d.lib for debug and python3.lib for release.


The cpp code I like to compile is:

#include <iostream>

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>


namespace p = boost::python;
namespace np = boost::python::numpy;

int main()
{
    Py_Initialize();
    np::initialize();

    return 0;
}


A few issues:

1) linker is looking for "boost_python3-vc141-mt-gd-x64-1_66.lib" but I got "libboost_python3-vc141-mt-gd-x64-1_66.lib"

Please tell me how to fix that. For now I just copied the libboost* files  and renamed them.

2) Linker error:

"__declspec(dllimport) void __cdecl boost::python::numpy::initialize(bool)"

How can I resolve that?

Thanks,
Christian



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
On 17 November 2017 at 09:16, Christian Henning via Boost-users <[hidden email]> wrote:
It seems that linking to static boost libs is not supported on Windows with Visual Studio 2017. Not sure why?

This is not the case, linking to static libs works just fine.

degski

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
Hi degski,

thanks for your insight.

Is it true to say, that by default boost::python is looking for the shared variants, like "boost_python3-vc141-mt-gd-x64-1_66"?. Do you know how to force boost to use static libs?

Thanks!

On Fri, Nov 17, 2017 at 4:32 PM, degski via Boost-users <[hidden email]> wrote:
On 17 November 2017 at 09:16, Christian Henning via Boost-users <[hidden email]> wrote:
It seems that linking to static boost libs is not supported on Windows with Visual Studio 2017. Not sure why?

This is not the case, linking to static libs works just fine.

degski

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
OK, I agree that linking to static libs works for boost::python out of the box. I think the problem lies with boost::python::numpy which only looks for dynamic libs.

Regards,
Christian

On Fri, Nov 17, 2017 at 4:37 PM, Christian Henning <[hidden email]> wrote:
Hi degski,

thanks for your insight.

Is it true to say, that by default boost::python is looking for the shared variants, like "boost_python3-vc141-mt-gd-x64-1_66"?. Do you know how to force boost to use static libs?

Thanks!

On Fri, Nov 17, 2017 at 4:32 PM, degski via Boost-users <[hidden email]> wrote:
On 17 November 2017 at 09:16, Christian Henning via Boost-users <[hidden email]> wrote:
It seems that linking to static boost libs is not supported on Windows with Visual Studio 2017. Not sure why?

This is not the case, linking to static libs works just fine.

degski

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [python] Linker error when initializing numpy

Boost - Users mailing list
In reply to this post by Boost - Users mailing list

 

From: Boost-users [mailto:[hidden email]] On Behalf Of degski via Boost-users
Sent: 17 November 2017 21:33
To: [hidden email]
Cc: degski
Subject: Re: [Boost-users] [python] Linker error when initializing numpy

 

On 17 November 2017 at 09:16, Christian Henning via Boost-users <[hidden email]> wrote:

Ø  It seems that linking to static boost libs is not supported on Windows with Visual Studio 2017. Not sure why?

 

Ø  This is not the case, linking to static libs works just fine.

 

But the static libraries are not created by default.

 

Personally I think that this is not ideal.

 

But as the number of libraries has increased, so the build time has become so long that doubling it to do static as well as shared/dynamic is a bit much.

 

(Personally, I find I only need to generate a small subset of ‘system’n’test’ libraries).

 

Perhaps we could we have a switch to the default b2 command after bootstrap that would do this?

 

I’d prefer to see at least a set of example command files that create both shared/dynamic and static libraries.

 

And a warning output that the default b2 will only create shared/dynamic libraries and a link on how to create the static ones.

 

This has caused a long stream of questions on various lists.

 

Paul

 

---

Paul A. Bristow

Prizet Farmhouse

Kendal UK LA8 8AB

+44 (0) 1539 561830

 

 

 

 

 

 


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users