Closed r1fl closed 4 years ago
You're the first person that I've heard of who is trying this on Windows, so you're breaking new ground here!
I don't think I've done anything in the code that won't work on windows, but I rarely use windows, so it's hard to say for sure.
The error you're getting suggests that either the libcec library isn't installed, or the compiler can't find the right headers for it. I don't really know how development on Windows works, so the best advice I can give it to make sure that you've installed the libcec library from pulse-eight and that your compiler can find the headers and the dll for it.
I am also trying this on Windows. Turns out, the code written in cec.cpp has issues with Windows (min/max stuff).
Though, after figuring out what caused that, I was able to get it to compile a little further. Now, it gets stuck on: LINK : fatal error LNK1181: cannot open input file 'cec.lib'
I'm not entirely sure what this means. There's no cec.lib anywhere, nor is one being generated.
cec.lib
is the object file that is being compiled from cec.cpp
, so my guess is you still have some compilation errors that you may have missed.
Could you share the complete output?
I'm also having this issue here's the log:
pip install cec Collecting cec Using cached https://files.pythonhosted.org/packages/ca/4e/84fae96b6744131a293ec8611dec173a22e06d9f228abc7f0f58f387f9d2/cec-0.2.6.tar.gz Installing collected packages: cec Running setup.py install for cec ... error Complete output from command c:\users\usuario\appdata\local\programs\python\python37-32\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Usuario\AppData\Local\Temp\pip-install-gdxxhjfu\cec\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\Usuario\AppData\Local\Temp\pip-record-3zuwswpq\install-record.txt --single-version-externally-managed --compile: running install running build running build_ext building 'cec' extension creating build creating build\temp.win32-3.7 creating build\temp.win32-3.7\Release C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Ic:\users\usuario\appdata\local\programs\python\python37-32\include -Ic:\users\usuario\appdata\local\programs\python\python37-32\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 /Tpcec.cpp /Fobuild\temp.win32-3.7\Release\cec.obj cec.cpp cec.cpp(32): fatal error C1083: NÆo ‚ poss¡vel abrir arquivo incluir: 'libcec/cec.h': No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\users\usuario\appdata\local\programs\python\python37-32\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Usuario\AppData\Local\Temp\pip-install-gdxxhjfu\cec\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\Usuario\AppData\Local\Temp\pip-record-3zuwswpq\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Usuario\AppData\Local\Temp\pip-install-gdxxhjfu\cec\
@Valkhan You have to build or install libCEC and provide proper include path to compiler and proper libpath to linker.
@nforro is there a Guide in this repo or elsewhere that I could follow?
Assuming libCEC is installed in C:\libCEC
(cec.dll
and libcec.dll
are in that directory), the following in setup.py
should work:
python_cec = Extension('cec', sources = [ 'cec.cpp', 'device.cpp' ],
include_dirs = [ 'C:/libCEC/include' ],
library_dirs = [ 'C:/libCEC' ],
libraries = [ 'cec' ])
I'm only guessing here, since I have no way to test this.
Step by step instructions would be the following:
libCEC
in the installer should be enough)python-cec
source code from heresetup.py
python.exe setup.py build
to build the extension (replace python.exe
with the full path to your Python executable)If it works, we can think about how to adjust setup.py
to make it work out of the box.
Thank you for the quick response, I'll try it later today and get back to you with the results, I already have libcec installed.
"If it works, we can think about how to adjust setup.py to make it work out of the box."
That would be awesome!
@nforro So here's my test results
I did as recommended, installed libcec on c:\libcec and all other dependencies
Downloaded the master branch.
My hardware is:
Some contextual software
#!/usr/bin/env python
from distutils.core import setup, Extension
# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++.
import distutils.sysconfig
cfg_vars = distutils.sysconfig.get_config_vars()
if "CFLAGS" in cfg_vars:
cfg_vars["CFLAGS"] = cfg_vars["CFLAGS"].replace("-Wstrict-prototypes", "")
if "OPT" in cfg_vars:
cfg_vars["OPT"] = cfg_vars["OPT"].replace("-Wstrict-prototypes", "")
python_cec = Extension('cec', sources = [ 'cec.cpp', 'device.cpp' ],
include_dirs=['C:\\libcec\\include'],
library_dirs=['C:\\libcec'], // This line was added, it was missing
libraries = [ 'cec' ])
setup(name='cec', version='0.2.7',
description="Python bindings for libcec",
license='GPLv2',
data_files=['COPYING'],
ext_modules=[python_cec])
python setup.py build
running build
running build_ext
building 'cec' extension
creating build
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files (x86)\Pulse-Eight\USB-CEC Adapter\include" -IC:\Users\Usuario\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\Usuario\AppData\Local\Programs\Python\Python37-32\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 /Tpcec.cpp /Fobuild\temp.win32-3.7\Release\cec.obj
cec.cpp
cec.cpp(32): fatal error C1083: Não é possível abrir arquivo incluir: 'libcec/cec.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
I've changed device.h and cec.cpp and replaced the includes: From libcec/cec.h to c:/libcec/include/cec.h
python setup.py build
running build
running build_ext
building 'cec' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\libcec\include -IC:\Users\Usuario\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\Usuario\AppData\Local\Programs\Python\Python37-32\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 /Tpcec.cpp /Fobuild\temp.win32-3.7\Release\cec.obj
cec.cpp
cec.cpp(159): error C2589: '(': token inválido no lado direito de '::'
cec.cpp(159): error C2062: tipo 'unknown-type' inesperado
cec.cpp(159): error C2059: erro de sintaxe: ')'
cec.cpp(674): warning C4244: 'inicializando': conversão de 'const int64_t' para 'long', possível perda de dados
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
Got invalid token and some syntax error.
If it helps the source language is Portuguese, cpp isn't my strong language, from here on I don't have many experience.
Can you help me once again? do you have any insight on a possible solution?
I'll also want to add, that this guidelines on installation as well as some of my steps could be added to readme
Pay attention to arguments passed to cl.exe
(the compiler). -I
sets additional include paths.
You can see "-IC:\Program Files (x86)\Pulse-Eight\USB-CEC Adapter\include"
in the first run, which seems kind of right, as C:\Program Files (x86)\Pulse-Eight\USB-CEC Adapter
is the default installation path for libCEC, but clearly it is not, as the headers are not there.
I have no clue where it comes from. Apparently, one can set INCLUDE
environment variable and the compiler will take it into account, and libCEC installer seems to be doing that. Which means no modification of setup.py
should be needed.
In the second run you can see -IC:\libcec\include
, which is correct. However, I didn't realize there is no libcec
subdirectory in C:\libcec\include
, so either create it and move the header files into it, or remove the libcec
part from the #include
directives.
I'll also want to add, that this guidelines on installation as well as some of my steps could be added to readme
Ideally we should make necessary adjustments so that no guidelines are needed.
@nforro I'll try your suggestions, thank you again for your time.
@nforro thank you for all of your support and time, but I couldn't get it to work, I'll stick to linux for the time being the device i'm working on will be returned to the owner this night and i'll be unable to procced with tests.
If the owners of this discussion doesn't have anything to add this issue may be closed by my understanting.
I have gotten stuck since 2 days ago on : LINK : fatal error LNK1181: cannot open input file 'cec.lib' too. @takuy this my out put.
running build running build_ext building 'cec' extension C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:/Program Files (x86)/Pulse-Eight/USB-CECAdapter/include" -IC:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\include -IC:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" /EHsc /Tpcec.cpp /Fobuild\temp.win-amd64-3.6\Release\cec.obj cec.cpp cec.cpp(256): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_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.16299.0\ucrt\stdio.h(1959): note: see declaration of '_snprintf' cec.cpp(441): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_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.16299.0\ucrt\stdio.h(1959): note: see declaration of '_snprintf' cec.cpp(895): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_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.16299.0\ucrt\stdio.h(1959): note: see declaration of '_snprintf' C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:/Program Files (x86)/Pulse-Eight/USB-CECAdapter/include" -IC:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\include -IC:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" /EHsc /Tpdevice.cpp /Fobuild\temp.win-amd64-3.6\Release\device.obj device.cpp device.cpp(66): warning C4068: unknown pragma C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:/Program Files (x86)/Pulse-Eight/USB-CECAdapter" /LIBPATH:C:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\libs /LIBPATH:C:\Users\achirawit_run\AppData\Local\Programs\Python\Python36\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64" cec.lib /EXPORT:PyInit_cec build\temp.win-amd64-3.6\Release\cec.obj build\temp.win-amd64-3.6\Release\device.obj /OUT:build\lib.win-amd64-3.6\cec.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\cec.cp36-win_amd64.lib LINK : fatal error LNK1181: cannot open input file 'cec.lib' error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.11.25503\\bin\\HostX86\\x64\\link.exe' failed with exit status 1181
I'm going to close this, see Windows installation instructions.
error when trying to install w\ windows 64 python 2.7