Installation af NLopt - Python - Windows

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg er temmelig ny til programmering, så jeg vil forsøge at gøre mig selv klar:


Jeg vil installere NLopt biblioteket (https://nlopt.readthedocs.io/en/latest/) for at kunne bruge det i et akademisk projekt, men jeg fortsætter med at få fejl. [2]


Filen 'README-WINDOWS', der fulgte med pakken, siger:



  Dette .zip-arkiv indeholder DLL-biblioteker og tilhørende overskrift (.h)
  og modul-definition (.def) filer af NLopt kompileret til Win64.

  
  For at linke til denne .dll filer fra Visual C ++, skal du
  opret en .lib 'import biblioteker' for det, og kan gøre det med 'lib'
  kommando, der følger med VC ++. Kør især:
       lib/def:libnlopt-0.def

  
  For at kompilere Matlab-plugin'et skal du bruge Matlab 'mex' kompilatoren på filen
  nlopt\_optimize.c (er sikker på at linke til libnlopt DLL) i matlab
  undermappe.

  
  At opbygge Python plugin (forudsat at du har Python og Numpy
  installeret), gør:
     python setup.py build\_ext --inplace

  
  De blev udarbejdet af GNU C compiler til MinGW, specifikt:
  x86\_64-w64-mingw32-gcc (GCC) 4.6.3



Jeg har formået at oprette .lib-filen, men når jeg udfører kommandoen 'python setup.py build\_ext --inplace' i anaconda-prompten, får jeg følgende fejl:


(base) C:UsersGermano
lopt>python setup.py build\_ext --inplace
running build\_ext
building '\_nlopt' extension
C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.14.26428inHostX86x64cl.exe /c     /nologo /Ox /W3 /GL /DNDEBUG /MD -I. -IC:UsersGermanoAnaconda3libsite-packages
umpycoreinclude -IC:UsersGermanoAnaconda3include -IC:UsersGermanoAnaconda3include "-IC:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.14.26428ATLMFCinclude" "-IC:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.14.26428include" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17134.0cppwinrt" /EHsc /Tpnlopt-python.cpp /Fobuild	emp.win-amd64-3.6Release
lopt-python.obj
nlopt-python.cpp
c:usersgermano
lopt
lopt.hpp(414): warning C4267: 'argument': conversion from 'size\_t' to 'unsigned int', possible loss of data
c:usersgermano
lopt
lopt.hpp(443): warning C4267: 'argument': conversion from 'size\_t' to 'unsigned int', possible loss of data
c:usersgermano
lopt
lopt.hpp(473): warning C4267: 'argument': conversion from 'size\_t' to 'unsigned int', possible loss of data
c:usersgermano
lopt
lopt.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 Studio2017CommunityVCToolsMSVC14.14.26428inHostX86x64link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:UsersGermanoAnaconda3libs /LIBPATH:C:UsersGermanoAnaconda3PCbuildamd64 "/LIBPATH:C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.14.26428ATLMFClibx64" "/LIBPATH:C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.14.26428libx64" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.17134.0ucrtx64" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.17134.0umx64" libnlopt-0.lib /EXPORT:PyInit\_\_nlopt build	emp.win-amd64-3.6Release
lopt-python.obj /OUT:C:UsersGermano
lopt\_nlopt.cp36-win\_amd64.pyd /IMPLIB:build	emp.win-amd64-3.6Release\_nlopt.cp36-win\_amd64.lib
Creating library build	emp.win-amd64-3.6Release\_nlopt.cp36-win\_amd64.lib and object build	emp.win-amd64-3.6Release\_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:UsersGermano
lopt\_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:UsersGermano
lopt>


Som jeg sagde, er jeg ny til programmering, så ingen af ​​dette giver mig mening. Jeg har forsøgt at kigge efter det i google, men ikke succes.

Bedste reference


Det viser sig, at jeg brugte den forkerte Visual C ++-prompt, at skifte til den rigtige løste problemet