Komnomnomnom / swigibpy

Third party Interactive Brokers Python API generated from TWS C++ API using SWIG.
http://github.com/Komnomnomnom/swigibpy/
Other
158 stars 35 forks source link

pip install (of 0.4.1) fails in Windows under Python 3.5.1 using VS2015 compiler #46

Open PatternMatching opened 8 years ago

PatternMatching commented 8 years ago

When attempting to install swigibpy using pip and Python 3.5.1 in Windows, I received the following error when attempting to compile swigibpy/IB/Shared/EClientSocketBase.cpp:

Macro definition of snprintf conflicts with Standard Library function declaration

A quick search on Google yielded a very helpful result. It appears that until now, many libraries (including IB API) used snprintf by defining it as _snprintf, since _snprintf was supported.

As of VS2015 (e.g. VC14), snprintf is officially supported, and it should therefore never be #define'd.

The offending line is in swigibpy/IB/Shared/StdAfx.h (8):

#define snprintf _snprintf

It would appear that IB fixed this in a release following the version included with swigibpy 0.4.1. I believe that this is also specific to the Python 3.x releases because Python 2.x builds point to earlier version of the VC++ compiler.

Not sure if this is super urgent given the pending push of version 0.5, but wanted to raise it in case it is a forcing function to move things along.

osteth commented 7 years ago

I am getting an the same error when trying to install. from my research, it looks like 'snprintf' is declared incorrectly and should be called as a standard function instead of declaring it because it has apparently been added to the standard lib? not sure honestly, just what I have managed to gather from trying to fix it myself.

pip install swigibpy

Collecting swigibpy Using cached swigibpy-0.4.1.tar.gz Building wheels for collected packages: swigibpy Running setup.py bdist_wheel for swigibpy ... error Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\me\AppData\Local\Temp\pip-build-b5wc6ast\swigibpy\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\me\AppData\Local\Temp\tmp46pw1p5jpip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.6 copying swigibpy.py -> build\lib.win-amd64-3.6 running build_ext building '_swigibpy' extension creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release\IB creating build\temp.win-amd64-3.6\Release\IB\PosixSocketClient C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" /EHsc /TpIB/PosixSocketClient/EClientSocketBase.cpp /Fobuild\temp.win-amd64-3.6\Release\IB/PosixSocketClient/EClientSocketBase.obj /D_CRT_SECURE_NO_DEPRECATE /EHsc /wd4355 /wd4800 EClientSocketBase.cpp C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition c:\users\me\appdata\local\temp\pip-build-b5wc6ast\swigibpy\ib\shared\StdAfx.h(8): note: see previous definition of 'snprintf' C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2


Failed building wheel for swigibpy Running setup.py clean for swigibpy Failed to build swigibpy Installing collected packages: swigibpy Running setup.py install for swigibpy ... error Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\me\AppData\Local\Temp\pip-build-b5wc6ast\swigibpy\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\me\AppData\Local\Temp\pip-n2axuo5h-record\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build\lib.win-amd64-3.6 copying swigibpy.py -> build\lib.win-amd64-3.6 running build_ext building '_swigibpy' extension creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release\IB creating build\temp.win-amd64-3.6\Release\IB\PosixSocketClient C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DIB_USE_STD_STRING=1 -IIB -IIB/PosixSocketClient -IIB/Shared -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" /EHsc /TpIB/PosixSocketClient/EClientSocketBase.cpp /Fobuild\temp.win-amd64-3.6\Release\IB/PosixSocketClient/EClientSocketBase.obj /D_CRT_SECURE_NO_DEPRECATE /EHsc /wd4355 /wd4800 EClientSocketBase.cpp C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition c:\users\me\appdata\local\temp\pip-build-b5wc6ast\swigibpy\ib\shared\StdAfx.h(8): note: see previous definition of 'snprintf' C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

----------------------------------------

Command "C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\me\AppData\Local\Temp\pip-build-b5wc6ast\swigibpy\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\me\AppData\Local\Temp\pip-n2axuo5h-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\me\AppData\Local\Temp\pip-build-b5wc6ast\swigibpy\

programmingwithalex commented 6 years ago

Commenting out line swigibpy/IB/Shared/StdAfx.h (8) let me install the package.