I'm trying to build a python wrapper for the library videoInput by ofTheo with Cython. I'm using Python 2.7 on Windows 8.1 x64 and Cython with the Visual Studio 2008 compiler (2012 is also installed). The first problem I faced was that the pre-built videoInput.lib is available for x86 only. For that I found a solution in a fork by liquidzym providing an x64 version. Unfortunately I got stuck with another problem. I get a linker error, LNK1120: 8 unresolved externals.
The extension in setup.py is defined as follows:
extensions = [Extension( name="pyVideoInput",
sources=['pyVideoInput.pyx'],
language="c++",
extra_objects= ['videoInput.lib'],
include_dirs= ['videoInput/videoInputSrcAndDemos/libs/'],
library_dirs= ['vi_x64/'])
]E:\Entwicklung\Python\pyvideoinput>setup.py build_ext --inplace
running build_ext
building 'pyVideoInput' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IvideoInput/videoInputSrcAndDemos/libs/ -IC:\Python27\include -IC:\Python27\PC /TppyVideoInput.cpp /Fobuild\temp.win-amd64-2.7\Release\pyVideoInput.obj
pyVideoInput.cpp
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:vi_x64/ /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /EXPORT:initpyVideoInput build\temp.win-amd64-2.7\Release\pyVideoInput.obj videoInput.lib /OUT:E:\Entwicklung\Python\pyvideoinput\pyVideoInput.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\pyVideoInput.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\pyVideoInput.pyd.manifest
videoInput.lib(videoInput.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_MSC_VER=1700' encountered; ignored
videoInput.lib(videoInput.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=0' encountered; ignored
videoInput.lib(videoInput.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:RuntimeLibrary=MT_StaticRelease' encountered; ignored
pyVideoInput.obj : warning LNK4197: export 'initpyVideoInput' specified multiple times; using first specification
Creating library build\temp.win-amd64-2.7\Release\pyVideoInput.lib and object build\temp.win-amd64-2.7\Release\pyVideoInput.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) referenced in function "char * __cdecl std::_Allocate<char>(unsigned __int64,char *)" (??$_Allocate@D@std@@YAPEAD_KPEAD@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPEBD@Z) referenced in function "public: bool __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned__int64,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA_N_K_N@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPEBD@Z) referenced in function "public: void __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Xran(void)const " (?_Xran@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAXXZ)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol "char const * __cdecl std::_Syserror_map(int)" (?_Syserror_map@std@@YAPEBDH@Z) referenced in function "public: virtual class
std::error_condition __cdecl std::_System_error_category::default_error_condition(int)const " (?default_error_condition@_System_error_category@std@@UEBA?AVerror_condition@2@H@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol "char const * __cdecl std::_Winerror_map(int)" (?_Winerror_map@std@@YAPEBDH@Z) referenced in function "public: virtual class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::_System_error_category::message(int)const " (?message@_System_error_category@std@@UEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@H@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol __imp_VariantInit referenced in function "private: long __cdecl videoInput::getDevice(struct IBaseFilter * *,int,wchar_t *,char *)" (?getDevice@videoInput@@AEAAJPEAPEAUIBaseFilter@@HPEA_WPEAD@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol __imp_VariantClear referenced in function "private: long __cdecl videoInput::getDevice(struct IBaseFilter * *,int,wchar_t *,char *)" (?getDevice@videoInput@@AEAAJPEAPEAUIBaseFilter@@HPEA_WPEAD@Z)
videoInput.lib(videoInput.obj) : error LNK2019: unresolved external symbol __imp_OleCreatePropertyFrame referenced in function "private: static long __cdecl videoInput::ShowFilterPropertyPages(structIBaseFilter *)" (?ShowFilterPropertyPages@videoInput@@CAJPEAUIBaseFilter@@@Z)
E:\Entwicklung\Python\pyvideoinput\pyVideoInput.pyd : fatal error LNK1120: 8 unresolved externals
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe"' failed with exit status 1120I found some hints, one related to name mangling, another related to different MSVC compiler versions, but none of them was really helpful.
It would be great if someone has an idea on how to solve this issue.
Thanks in advance!
Best, Michael