boost.numpy functions are throwing unresolved extern symbol link errors

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

boost.numpy functions are throwing unresolved extern symbol link errors

Boost - Dev mailing list
   Hello Boost-Community I have asked the following question everywhere
   but nowhere has it been answered. I have now been advised to ask here.

   I really hope there is someone on this mail list who can help me.
   Unfortunately I don't have much time left and would be very grateful
   for an answer.


   With kind regards

   Max


   My Question:


   I'm using normal Boost.NumPy functions in C++ like ndarray::get_data(),
   and I get a "reference to unresolved external symbol" error. The .lib's
   are linked and I have no approach on how to solve the error.

   I am using Boost 1.74.

   Here is a Code example:

   #include<boost/python/numpy.hpp>

   using namespace boost;


   void func(python::object _obj)

   {

       python::numpy::ndarray my_ndarray =
   python::extract<boost::python::numpy::ndarray>(_obj.attr("Member_01"));


       char* data = my_ndarray.get_data();

   }


   BOOST_PYTHON_MODULE(ogwa_acc)

   {

       python::def("func", func);

   }


   Thats the one of the unresolved symbols: ""__declspec(dllimport)
   public: char * __cdecl
   boost::python::numpy::ndarray::get_data(void)const "
   (_imp?get_data@ndarray@numpy@python@boost@@QEBAPEADXZ)"



   I am using the normal Visual Studio linker and this is my linker
   config:


   /OUT:"D:\OthelloGame_withAI\x64\Debug\ogwa_acc.pyd" /MANIFEST /NXCOMPAT

   /PDB:"D:\OthelloGame_withAI\x64\Debug\ogwa_acc.pdb" /DYNAMICBASE

   "boost_numpy38-vc142-mt-gd-x64-1_74.lib"
   "boost_numpy38-vc142-mt-x64-1_74.lib"

   "boost_python38-vc142-mt-gd-x64-1_74.lib" "boost_python38-vc142-mt-x64-

   1_74.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
   "comdlg32.lib"

   "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib"
   "odbc32.lib"

   "odbccp32.lib" /IMPLIB:"D:\OthelloGame_withAI\x64\Debug\ogwa_acc.lib"
   /DEBUG

   /DLL /MACHINE:X64 /INCREMENTAL

   /PGD:"D:\OthelloGame_withAI\x64\Debug\ogwa_acc.pgd" /SUBSYSTEM:CONSOLE

   /MANIFESTUAC:"level='asInvoker' uiAccess='false'"

   /ManifestFile:"x64\Debug\ogwa_acc.pyd.intermediate.manifest"

   /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files\Python38\libs"

   /LIBPATH:"D:\OthelloGame_withAI\Third-Party\boost_1_74_0\finished_libs"
   /TLBID:1


   D:\OthelloGame_withAI\Third-Party\boost_1_74_0\finished_libs is the
   location of:


   boost_numpy38-vc142-mt-gd-x64-1_74.lib;

   boost_python38-vc142-mt-gd-x64- 1_74.lib;

   boost_numpy38-vc142-mt-x64-1_74.lib;

   boost_python38-vc142-mt-x64-1_74.lib

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: boost.numpy functions are throwing unresolved extern symbol link errors

Boost - Dev mailing list
Hello,

I'm unfortunately not familiar enough with the platform (Windows) or
this compiler (MSVC) to help, but I would like to add some notes in case
someone else on this list has ideas:

Compiling a trivial C++ applet based on code such as
https://boostorg.github.io/python/doc/html/numpy/tutorial/ndarray.html 
on Linux simply requires a command such as

```

g++ -I /usr/include/python3.8 -o np_test np_test.cpp -lboost_numpy38
-lboost_python38 -lpython3.8
```

I find particularly confusing that the MSVC linker would generate a
missing symbol error for the `ndarray::get_data()` function, given that
this function (as defined in
https://github.com/boostorg/python/blob/develop/include/boost/python/numpy/ndarray.hpp#L101)
ought to be inlined, and not generate a symbol at all.

Does anyone familiar with this platform have an idea under what
circumstances this may result in a link error ? (See the exact
command-line in the previous post).

Thanks,

Stefan
--

       ...ich hab' noch einen Koffer in Berlin...


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: boost.numpy functions are throwing unresolved extern symbol link errors

Boost - Dev mailing list
On 1/20/21 6:23 AM, Stefan Seefeld via Boost wrote:

> Hello,
>
> I'm unfortunately not familiar enough with the platform (Windows) or
> this compiler (MSVC) to help, but I would like to add some notes in case
> someone else on this list has ideas:
>
> Compiling a trivial C++ applet based on code such as
> https://boostorg.github.io/python/doc/html/numpy/tutorial/ndarray.html 
> on Linux simply requires a command such as
>
> ```
>
> g++ -I /usr/include/python3.8 -o np_test np_test.cpp -lboost_numpy38
> -lboost_python38 -lpython3.8
> ```
>
> I find particularly confusing that the MSVC linker would generate a
> missing symbol error for the `ndarray::get_data()` function, given that
> this function (as defined in
> https://github.com/boostorg/python/blob/develop/include/boost/python/numpy/ndarray.hpp#L101)
> ought to be inlined, and not generate a symbol at all.
>
> Does anyone familiar with this platform have an idea under what
> circumstances this may result in a link error ?

The class is marked with BOOST_NUMPY_DECL, which, I assume, is
__declspec(dllexport)/(dllimport) on Windows. This means that when
compiling the user's code the compiler may look for the imported
function from the dll when inlining does not happen, which is usual in
debug builds, for example.

The fact that there is no such function probably means that the class is
never included when Boost.Python is compiled (i.e. when the class is
marked as dllexport).

Marking the whole class as dllexport/dllimport has other consequences,
such as exporting type information for the class. If this is not needed,
I would suggest marking individual members to export/import and not the
whole class.

> (See the exact
> command-line in the previous post).

What previous post?

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: boost.numpy functions are throwing unresolved extern symbol link errors

Boost - Dev mailing list
On 1/20/21 11:48 AM, Andrey Semashev wrote:

> On 1/20/21 6:23 AM, Stefan Seefeld via Boost wrote:
>> Hello,
>>
>> I'm unfortunately not familiar enough with the platform (Windows) or
>> this compiler (MSVC) to help, but I would like to add some notes in
>> case someone else on this list has ideas:
>>
>> Compiling a trivial C++ applet based on code such as
>> https://boostorg.github.io/python/doc/html/numpy/tutorial/ndarray.html 
>> on Linux simply requires a command such as
>>
>> ```
>>
>> g++ -I /usr/include/python3.8 -o np_test np_test.cpp -lboost_numpy38
>> -lboost_python38 -lpython3.8
>> ```
>>
>> I find particularly confusing that the MSVC linker would generate a
>> missing symbol error for the `ndarray::get_data()` function, given
>> that this function (as defined in
>> https://github.com/boostorg/python/blob/develop/include/boost/python/numpy/ndarray.hpp#L101)
>> ought to be inlined, and not generate a symbol at all.
>>
>> Does anyone familiar with this platform have an idea under what
>> circumstances this may result in a link error ?
>
> The class is marked with BOOST_NUMPY_DECL, which, I assume, is
> __declspec(dllexport)/(dllimport) on Windows. This means that when
> compiling the user's code the compiler may look for the imported
> function from the dll when inlining does not happen, which is usual in
> debug builds, for example.
>
> The fact that there is no such function probably means that the class is
> never included when Boost.Python is compiled (i.e. when the class is
> marked as dllexport).

Actually, no, it must be indirectly included in src/numpy/ndarray.cpp.
But that file is a part of boost_numpy library, not boost_python. Does
it get exported from boost_numpy?

> Marking the whole class as dllexport/dllimport has other consequences,
> such as exporting type information for the class. If this is not needed,
> I would suggest marking individual members to export/import and not the
> whole class.
>
>> (See the exact command-line in the previous post).
>
> What previous post?


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: boost.numpy functions are throwing unresolved extern symbol link errors

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

> On 19. Jan 2021, at 13:52, Max Fetz via Boost <[hidden email]> wrote:
>
>   Hello Boost-Community I have asked the following question everywhere
>   but nowhere has it been answered. I have now been advised to ask here.
>
>   I really hope there is someone on this mail list who can help me.
>   Unfortunately I don't have much time left and would be very grateful
>   for an answer.

Boost.Numpy is great if you are already using Boost as a dependency for your project and you don't want to add another dependency. If adding another dependency is an option, I would recommend to have a look at pybind11, which has a similar API and more features.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost