ddemidov / mba

Scattered data interpolation with multilevel B-Splines
MIT License
73 stars 23 forks source link

NameError: name 'mba2' is not defined #9

Closed KareliaPena closed 5 years ago

KareliaPena commented 5 years ago

Hi, I don't have much experience in using C++ in Python. First time I tried python setup.py install

running install running bdist_egg running egg_info creating pymba.egg-info writing pymba.egg-info\PKG-INFO writing dependency_links to pymba.egg-info\dependency_links.txt writing top-level names to pymba.egg-info\top_level.txt writing manifest file 'pymba.egg-info\SOURCES.txt' reading manifest file 'pymba.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'python\pybind11\include\pybind11*.h' warning: no files found matching 'RELEASE-VERSION' writing manifest file 'pymba.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_ext building 'pymba' extension creating build creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release\python C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ipython/pybind11/include/ -I. -ID:\Karelia\Anaconda3\envs\python3.7OpenCV-gpu-Grid\include -ID:\Karelia\Anaconda3\envs\python3.7OpenCV-gpu-Grid\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tppython/pymba.cpp /Fobuild\temp.win-amd64-3.6\Release\python/pymba.obj -O3 -std=c++11 cl : Command line warning D9002 : ignoring unknown option '-O3' cl : Command line warning D9002 : ignoring unknown option '-std=c++11' pymba.cpp python/pymba.cpp(211): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h(2263): note: see declaration of 'sscanf' python/pymba.cpp(72): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data python/pymba.cpp(56): note: while compiling class template member function 'pybind11::array_t<double,16> python_mba<3>::apply(pybind11::array_t<double,16>) const' python/pymba.cpp(202): note: see reference to function template instantiation 'pybind11::array_t<double,16> python_mba<3>::apply(pybind11::array_t<double,16>) const' being compiled C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits(724): note: see reference to class template instantiation 'python_mba<3>' being compiled D:\Karelia\Anaconda3\envs\python3.7OpenCV-gpu-Grid\include\pybind11/pybind11.h(1030): note: see reference to class template instantiation 'std::is_polymorphic<pythonmba<3>>' being compiled python/pymba.cpp(164): note: see reference to class template instantiation 'pybind11::class<python_mba<3>>' being compiled python/pymba.cpp(214): note: see reference to function template instantiation 'void register_mba<3>(pybind11::module &)' being compiled .\mba/mba.hpp(512): warning C4244: '=': conversion from 'double' to '_Ty', possible loss of data with [ _Ty=size_t ] .\mba/mba.hpp(506): note: while compiling class template member function 'double mba::detail::control_lattice_sparse<3>::operator ()(const std::array<double,3> &) const' C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\type_traits(616): note: see reference to class template instantiation 'mba::detail::control_lattice_sparse<3>' being compiled C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1227): note: see reference to class template instantiation 'std::is_convertible<_Yty ,_Ty >' being compiled with [ _Yty=mba::detail::control_lattice_sparse<3>, _Ty=mba::detail::control_lattice<3> ] .\mba/mba.hpp(776): note: see reference to class template instantiation 'std::_SP_pointer_compatible<mba::detail::control_lattice_sparse<3>,mba::detail::control_lattice<3>>' being compiled .\mba/mba.hpp(676): note: see reference to function template instantiation 'void mba::MBA<3>::init<CooIter,ValIter>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter,unsigned int,double,double,std::function<double (std::array<double,3>)>)' being compiled with [ CooIter=const point , ValIter=const double ] .\mba/mba.hpp(672): note: see reference to function template instantiation 'void mba::MBA<3>::init<CooIter,ValIter>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter,unsigned int,double,double,std::function<double (std::array<double,3>)>)' being compiled with [ CooIter=const point , ValIter=const double ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::MBA<3>::MBA<const point,const double>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter,unsigned int,double,double,std::function<double (std::array<double,3>)>)' being compiled with [ CooIter=const point , ValIter=const double ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::MBA<3>::MBA<const point,const double>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter,unsigned int,double,double,std::function<double (std::array<double,3>)>)' being compiled with [ CooIter=const point , ValIter=const double ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<point&,point&,index&,const point&,const point&,const double&,_Fx&,double&,double&,std::function<double (const std::array<double,3> &)>&>(point &,point &,index &,const point &,const point &,const double &,_Fx &,double &,double &,std::function<double (const std::array<double,3> &)> &)' being compiled with [ _Ty=mba::MBA<3>, _Fx=int ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<point&,point&,index&,const point&,const point&,const double&,_Fx&,double&,double&,std::function<double (const std::array<double,3> &)>&>(point &,point &,index &,const point &,const point &,const double &,_Fx &,double &,double &,std::function<double (const std::array<double,3> &)> &)' being compiled with [ _Ty=mba::MBA<3>, _Fx=int ] python/pymba.cpp(152): note: see reference to function template instantiation 'std::shared_ptr<mba::MBA<3>> std::make_shared<mba::MBA<3>,point&,point&,index&,const point&,const point&,const double&,int&,double&,double&,std::function<double (const std::array<double,3> &)>&>(point &,point &,index &,const point &,const point &,const double &,int &,double &,double &,std::function<double (const std::array<double,3> &)> &)' being compiled python/pymba.cpp(104): note: while compiling class template member function 'void python_mba<3>::init(pybind11::array_t<double,16>,pybind11::array_t<double,16>,pybind11::array_t<int,16>,pybind11::array_t<double,16>,pybind11::array_t<double,16>,std::function<double (const std::array<double,3> &)>,int,double,double)' python/pymba.cpp(53): note: see reference to function template instantiation 'void python_mba<3>::init(pybind11::array_t<double,16>,pybind11::array_t<double,16>,pybind11::array_t<int,16>,pybind11::array_t<double,16>,pybind11::array_t<double,16>,std::function<double (const std::array<double,3> &)>,int,double,double)' being compiled .\mba/mba.hpp(373): warning C4244: '=': conversion from 'double' to '_Ty', possible loss of data with [ _Ty=size_t ] .\mba/mba.hpp(367): note: while compiling class template member function 'double mba::detail::control_lattice_dense<3>::operator ()(const std::array<double,3> &) const' .\mba/mba.hpp(753): note: see reference to class template instantiation 'mba::detail::control_lattice_dense<3>' being compiled .\mba/mba.hpp(332): warning C4244: '=': conversion from 'double' to '_Ty', possible loss of data with [ _Ty=size_t ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::detail::control_lattice_dense<3>::control_lattice_dense<const point,_Ty>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter)' being compiled with [ _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>, CooIter=const point , ValIter=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::detail::control_lattice_dense<3>::control_lattice_dense<const point,_Ty>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter)' being compiled with [ _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>, CooIter=const point , ValIter=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const std::array<double,3>&,const std::array<double,3>&,index&,const point&,const point&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>(const std::array<double,3> &,const std::array<double,3> &,index &,const point &,const point &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> &&)' being compiled with [ _Ty=mba::detail::control_lattice_dense<3> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const std::array<double,3>&,const std::array<double,3>&,index&,const point&,const point&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>(const std::array<double,3> &,const std::array<double,3> &,index &,const point &,const point &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> &&)' being compiled with [ _Ty=mba::detail::control_lattice_dense<3> ] .\mba/mba.hpp(751): note: see reference to function template instantiation 'std::shared_ptr<mba::detail::control_lattice_dense<3>> std::make_shared<mba::detail::control_lattice_dense<3>,const std::array<double,3>&,const std::array<double,3>&,std::array<size_t,3>&,CooIter&,CooIter&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>>(const std::array<_Ty,3> &,const std::array<_Ty,3> &,std::array<size_t,3> &,CooIter &,CooIter &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>> &&)' being compiled with [ CooIter=const point , _Ty=double ] .\mba/mba.hpp(475): warning C4244: '=': conversion from 'double' to '_Ty', possible loss of data with [ _Ty=size_t ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::detail::control_lattice_sparse<3>::control_lattice_sparse<const point,_Ty>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter)' being compiled with [ _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>, CooIter=const point , ValIter=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1801): note: see reference to function template instantiation 'mba::detail::control_lattice_sparse<3>::control_lattice_sparse<const point,_Ty>(const std::array<double,3> &,const std::array<double,3> &,std::array<size_t,3>,CooIter,CooIter,ValIter)' being compiled with [ _Ty=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>, CooIter=const point , ValIter=std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const std::array<double,3>&,const std::array<double,3>&,index&,const point&,const point&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>(const std::array<double,3> &,const std::array<double,3> &,index &,const point &,const point &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> &&)' being compiled with [ _Ty=mba::detail::control_lattice_sparse<3> ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const std::array<double,3>&,const std::array<double,3>&,index&,const point&,const point&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>(const std::array<double,3> &,const std::array<double,3> &,index &,const point &,const point &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>> &&)' being compiled with [ _Ty=mba::detail::control_lattice_sparse<3> ] .\mba/mba.hpp(776): note: see reference to function template instantiation 'std::shared_ptr<mba::detail::control_lattice_sparse<3>> std::make_shared<mba::detail::control_lattice_sparse<3>,const std::array<double,3>&,const std::array<double,3>&,std::array<size_t,3>&,CooIter&,CooIter&,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>>(const std::array<_Ty,3> &,const std::array<_Ty,3> &,std::array<size_t,3> &,CooIter &,CooIter &,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>> &&)' being compiled with [ CooIter=const point , _Ty=double ] .\mba/mba.hpp(109): warning C4267: '=': conversion from 'size_t' to '_Ty', possible loss of data with [ _Ty=int ] .\mba/mba.hpp(105): note: while compiling class template member function 'void mba::detail::multi_array<double,1>::init(std::array<size_t,1>)' .\mba/mba.hpp(79): note: see reference to function template instantiation 'void mba::detail::multi_array<double,1>::init(std::array<size_t,1>)' being compiled .\mba/mba.hpp(444): note: see reference to class template instantiation 'mba::detail::multi_array<double,1>' being compiled creating D:\Karelia\Google Drive\Shared Documents\Python\Grid Reconstruction\mba-0.2\mba-0.2\build\lib.win-amd64-3.6 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:D:\Karelia\Anaconda3\envs\python3.7OpenCV-gpu-Grid\libs /LIBPATH:D:\Karelia\Anaconda3\envs\python3.7OpenCV-gpu-Grid\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64" /EXPORT:PyInit_pymba build\temp.win-amd64-3.6\Release\python/pymba.obj /OUT:build\lib.win-amd64-3.6\pymba.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\python\pymba.cp36-win_amd64.lib LINK : error LNK2001: unresolved external symbol PyInit_pymba build\temp.win-amd64-3.6\Release\python\pymba.cp36-win_amd64.lib : fatal error LNK1120: 1 unresolved externals error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe' failed with exit status 1120

I tried to run the example on spyder: I get

interp = mba2(lo=[-0.1,-0.1], hi=[1.1,1.1], grid=[3,3],

NameError: name 'mba2' is not defined

I successfully ran this example (https://github.com/pybind/python_example) using pybind11 so I tried to follow sort of the same. Do you have any idea about what is wrong or any suggestions?

snaphat commented 5 years ago

The problem is that the python library name is set to "pymba" in the setup.py script. But, internally the bindings use PyInit_mba() as the exported function name. Ergo, the error:

LINK : error LNK2001: unresolved external symbol PyInit_pymba

occurs because the exported symbol PyInit_pymba doesn't exist. Changing the library name to "mba" fixes the issue.

ddemidov commented 5 years ago

Thank you for the solution, @snaphat. @KareliaPena , does e2003d8 work for you?

KareliaPena commented 5 years ago

Yes @ddemidov. It worked. Thank you @snaphat