conan icon indicating copy to clipboard operation
conan copied to clipboard

Creating package with boost python cannot link boost python numpy libs

Open mpconte opened this issue 3 years ago • 3 comments
trafficstars

Environment Details (include every applicable attribute)

  • Operating System+version: Windows 10
  • Compiler+version: Visual Studio 16 2019
  • Conan version: 1.48.0
  • Python version: 3.9 (with numpy installed)

Steps to reproduce (Include if Applicable)

Clone the following repo here and run the command

conan create . -o boost:shared=True -o boost:without_python=False -o boost:python_executable=<Path to python 3 exe>

Logs

LINK : warning LNK4217: symbol '??1dtype@numpy@python@boost@@QEAA@XZ (public: __cdecl boost::python::numpy::dtype::~
dtype(void))' defined in 'libboost_numpy39.lib(dtype.obj)' is imported by 'main.obj' in function 'main' [D:\software
\.conan\data\sample\1.0\sensoft\testing\build\d9a55a06050e0a7e3de1cbca38d6e88fc6fd70ca\build\code\main.vcxproj]
LINK : warning LNK4217: symbol '??1ndarray@numpy@python@boost@@QEAA@XZ (public: __cdecl boost::python::numpy::ndarra
y::~ndarray(void))' defined in 'libboost_numpy39.lib(ndarray.obj)' is imported by 'main.obj' in function 'main' [D:\
software\.conan\data\sample\1.0\sensoft\testing\build\d9a55a06050e0a7e3de1cbca38d6e88fc6fd70ca\build\code\main.vcxpr
oj]
LINK : warning LNK4217: symbol '?from_data_impl@detail@numpy@python@boost@@YA?AVndarray@234@PEAXAEBVdtype@234@AEBVob
ject@api@34@22_N@Z (class boost::python::numpy::ndarray __cdecl boost::python::numpy::detail::from_data_impl(void *,
class boost::python::numpy::dtype const &,class boost::python::api::object const &,class boost::python::api::object
const &,class boost::python::api::object const &,bool))' defined in 'libboost_numpy39.lib(ndarray.obj)' is imported
by 'main.obj' in function 'main' [D:\software\.conan\data\sample\1.0\sensoft\testing\build\d9a55a06050e0a7e3de1cbca3
8d6e88fc6fd70ca\build\code\main.vcxproj]
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char * __cdecl boost::python::nu
mpy::ndarray::get_data(void)const " (__imp_?get_data@ndarray@numpy@python@boost@@QEBAPEADXZ) referenced in function
main [D:\software\.conan\data\sample\1.0\sensoft\testing\build\d9a55a06050e0a7e3de1cbca38d6e88fc6fd70ca\build\code\m
ain.vcxproj]
D:\software\.conan\data\sample\1.0\sensoft\testing\build\d9a55a06050e0a7e3de1cbca38d6e88fc6fd70ca\build\Release\main
.exe : fatal error LNK1120: 1 unresolved externals [D:\software\.conan\data\sample\1.0\sensoft\testing\build\d9a55a0
6050e0a7e3de1cbca38d6e88fc6fd70ca\build\code\main.vcxproj]-->

mpconte avatar May 12 '22 16:05 mpconte

As a first check, I would try to do a local build of Python, forcing --build=boost --build=sample and see what happens.

There is a chance that the boost linking python in ConanCenter builds and your local python do not fully match, and that could be creating the error.

memsharded avatar May 12 '22 16:05 memsharded

@memsharded That seems to have done it. Thank you.

mpconte avatar May 20 '22 18:05 mpconte

@memsharded I was having a similar issue to this one, but it presented differently. During a conan install, I received this error message: boost/1.79.0: WARN: Boost component 'numpy' is missing libraries. Try building boost with '-o boost:without_numpy'. (Option is not guaranteed to exist) ERROR: boost/1.79.0: Error in package_info() method, line 1664 raise ConanException("These libraries were expected to be built, but were not built: {}".format(non_built)) ConanException: These libraries were expected to be built, but were not built: {'libboost_numpy310'} However your suggested fix corrected the problem! Thank you so much for suggesting this, I've spent many hours searching for any explanation whatsoever.

However, I don't entirely understand why this fixes the issue. Boost was being built already, so the build=boost flag should not change anything, and I do not know what sample is for, or what it is from. Can you please provide some explanation so that I can 'own' the fix, and not blindly rely on it? Thank you!

cwsamuelson avatar Aug 02 '22 20:08 cwsamuelson