Я довольно новичок в программировании, поэтому я попытаюсь прояснить ситуацию:
Я хочу установить библиотеку NLopt (https://nlopt.readthedocs.io/en/latest/), чтобы использовать ее в академическом проекте, но я продолжаю получать ошибки.
Файл «README-WINDOWS», поставляемый с пакетом, говорит:
Этот ZIP-архив содержит библиотеки DLL и связанный заголовок (.h) и файлы определения модуля (.def) NLopt, скомпилированные для Win64.
Для того чтобы связать эти файлы DLL из Visual C ++, вам нужно создать .lib «библиотеки импорта» для него, иэто можно сделать с помощью команды "lib", поставляемой с VC ++. В частности, выполните команду: lib /def:libnlopt-0.def
Чтобы скомпилировать плагин Matlab, используйте в файле компилятор Matlab "mex"nlopt_optimize.c (обязательно ссылка на библиотеку libnlopt) в подкаталоге matlab.
Чтобы создать плагин Python (при условии, что у вас установлены Python и Numpy), выполните: python setup.py build_ext --inplace
Они были скомпилированы GNU Cкомпилятор для MinGW, а именно: x86_64-w64-mingw32-gcc (GCC) 4.6.3
Мне удалось создать файл .lib, но когда я выполняю «python setup.py build_ext --inplace "в приглашении anaconda, я получаю следующую ошибку:
(base) C:\Users\Germano\nlopt>python setup.py build_ext --inplace
running build_ext
building '_nlopt' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I. -IC:\Users\Germano\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\Germano\Anaconda3\include -IC:\Users\Germano\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /EHsc /Tpnlopt-python.cpp /Fobuild\temp.win-amd64-3.6\Release\nlopt-python.obj
nlopt-python.cpp
c:\users\germano\nlopt\nlopt.hpp(414): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(443): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(473): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(483): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
nlopt-python.cpp(5249): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(5256): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(8406): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8411): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8466): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(8467): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(8475): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8480): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(9443): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(9444): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(9784): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(9785): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10357): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10358): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10496): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10497): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10763): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10764): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(11012): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(11013): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(11493): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(11494): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12060): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12061): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12170): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12171): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12240): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12241): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12367): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12368): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Germano\Anaconda3\libs /LIBPATH:C:\Users\Germano\Anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64" libnlopt-0.lib /EXPORT:PyInit__nlopt build\temp.win-amd64-3.6\Release\nlopt-python.obj /OUT:C:\Users\Germano\nlopt\_nlopt.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.lib
Creating library build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.exp
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_algorithm
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_remove_equality_constraints
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_lower_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_munge
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_ftol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_population
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_maxtime
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_copy
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_maxtime
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_abs1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_xtol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_stopval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_ftol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_version
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_population
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_ftol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_max_objective
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_initial_step1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_lower_bounds1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_maxeval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_inequality_constraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_local_optimizer
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_inequality_mconstraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_srand
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_dimension
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_force_stop
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_xtol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_algorithm_name
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_maxeval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_default_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_remove_inequality_constraints
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_vector_storage
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_stopval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_upper_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_srand_time
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_upper_bounds1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_equality_constraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_ftol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_create
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_vector_storage
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_destroy
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_lower_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_upper_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_min_objective
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_force_stop
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_equality_mconstraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_optimize
C:\Users\Germano\nlopt\_nlopt.cp36-win_amd64.pyd : fatal error LNK1120: 51 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120
(base) C:\Users\Germano\nlopt>
Как я уже сказал, я новичок в программировании, поэтому для меня ничего из этого не имеет особого смысла.Я пытался найти его в Google, но безуспешно.