Libusbpp
Libusbpp copied to clipboard
fatal error: 'chrono' file not found
On Mac OS X I have:
In file included from LibusbTest.cpp:18:
In file included from ../headers/libusbpp.h:3:
In file included from ../headers/device.h:2:
In file included from ../headers/Configuration.h:5:
In file included from ../headers/interface.h:6:
In file included from ../headers/Endpoint.h:7:
../headers/Transfer.h:4:10: fatal error: 'chrono' file not found
# include <chrono>
^
1 error generated.
make: **\* [LibusbTest] Error 1```
I also do not have the `<future>` header.
I guess that is because my C++ compiler (clang) is not yet C++11 compliant.
`$ c++ --version
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix`
I also tried with GCC but I have the same problem:
`$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)`
After a quick search, I came up with this:
http://urfoex.blogspot.com/2012/06/c11-fixing-bug-to-use-chrono-with-clang.html
There's a link to a patch....I'll just quote the page verbatim:
"""Funny thing: there is a fix to it: http://clang.llvm.org/libstdc++4.7-clang11.patch
So I tried the following:
- Opening the file: /usr/include/c++/4.7/type_traits
- Going down to line 1749
- Changing the line to what the patch said: { typedef typename decay<decltype(true ? declval<_Tp>() : declval<_Up>())>::type type; };"""
I'm not sure if that will fix the issue, but I wrote the library using C++11 features, the latest GCC should support all of the ones I've used. (VS2012 has the least, of the two).
Maybe there's an easy way to use boost as a substitute for missing C++11 features?
Also, you may want to check this:
http://stackoverflow.com/questions/4574246/can-i-use-c11-with-xcode
I installed gcc-4.7 and it now complains about conio.h.
mymacmini:LibusbTest xiaofanc$ g++-4.7 -I../headers LibusbTest.cpp -o LibusbTestIn file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/chrono:35:0, from ../headers/Transfer.h:4, from ../headers/Endpoint.h:7, from ../headers/interface.h:6, from ../headers/Configuration.h:5, from ../headers/device.h:2, from ../headers/libusbpp.h:3, from LibusbTest.cpp:18: /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. LibusbTest.cpp:23:19: fatal error: conio.h: No such file or directory compilation terminated.
mymacmini:LibusbTest xiaofanc$ g++-4.7 -std=c++11 -I../headers LibusbTest.cpp -o LibusbTest LibusbTest.cpp:23:19: fatal error: conio.h: No such file or directory compilation terminated.
BTW, I install gcc-4.7 using Homebrew-dupes gcc formula for my Mac (OS X Lion 10.7.4).
mymacmini:LibusbTest xiaofanc$ g++-4.7 -v Using built-in specs. COLLECT_GCC=g++-4.7 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.7.1/gcc/libexec/gcc/x86_64-apple-darwin11.4.0/4.7.1/lto-wrapper Target: x86_64-apple-darwin11.4.0 Configured with: ../configure --enable-languages=c,c++ --prefix=/usr/local/Cellar/gcc/4.7.1/gcc --datarootdir=/usr/local/Cellar/gcc/4.7.1/share --bindir=/usr/local/Cellar/gcc/4.7.1/bin --program-suffix=-4.7 --with-gmp=/usr/local/Cellar/gmp/5.0.5 --with-mpfr=/usr/local/Cellar/mpfr/3.1.1-p2 --with-mpc=/usr/local/Cellar/libmpc/1.0.1 --with-system-zlib --enable-stage1-checking --enable-plugin --enable-lto --disable-multilib --disable-nls Thread model: posix gcc version 4.7.1 (GCC)
Wow, after a minute of digging, it looks like conio.h is actually non-standard! I used it simply to provide a way to pause to read the output. I guess I need to pickup a mac-mini...
The conio issue should be fixed now.
Thanks, now the conio issue is fixed but there are more problems. I guess the C++11 support of gcc 4.7.1 is really experimental.
mymacmini:LibusbTest xiaofanc$ g++-4.7 -std=c++11 -I../headers LibusbTest.cpp -o LibusbTest
LibusbTest.cpp: In function 'int main(int, char*)':
LibusbTest.cpp:90:54: error: no matching function for call to 'std::exception::exception(const char [27])'
LibusbTest.cpp:90:54: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [27]' to 'const std::exception&'
LibusbTest.cpp:195:74: error: no matching function for call to 'std::exception::exception(const char [45])'
LibusbTest.cpp:195:74: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [45]' to 'const std::exception&'
LibusbTest.cpp:363:54: error: no matching function for call to 'std::exception::exception(const char [27])'
LibusbTest.cpp:363:54: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [27]' to 'const std::exception&'
LibusbTest.cpp:447:54: error: no matching function for call to 'std::exception::exception(const char [27])'
LibusbTest.cpp:447:54: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [27]' to 'const std::exception&'
LibusbTest.cpp:478:82: warning: deprecated conversion from string constant to 'char' [-Wwrite-strings]
LibusbTest.cpp:483:52: error: 'memset' was not declared in this scope
LibusbTest.cpp:580:54: error: no matching function for call to 'std::exception::exception(const char [27])'
LibusbTest.cpp:580:54: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [27]' to 'const std::exception&'
LibusbTest.cpp:622:84: warning: deprecated conversion from string constant to 'char_' [-Wwrite-strings]
LibusbTest.cpp:627:52: error: 'memset' was not declared in this scope
LibusbTest.cpp:723:54: error: no matching function for call to 'std::exception::exception(const char [27])'
LibusbTest.cpp:723:54: note: candidates are:
In file included from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/new:42:0,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/ext/new_allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/x86_64-apple-darwin11.4.0/bits/c++allocator.h:34,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/bits/allocator.h:48,
from /usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:65,
from ../headers/Configuration.h:2,
from ../headers/device.h:2,
from ../headers/libusbpp.h:3,
from LibusbTest.cpp:18:
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: std::exception::exception()
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:65:5: note: candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: constexpr std::exception::exception(const std::exception&)
/usr/local/Cellar/gcc/4.7.1/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/exception:62:9: note: no known conversion for argument 1 from 'const char [27]' to 'const std::exception&'
LibusbTest.cpp:765:84: warning: deprecated conversion from string constant to 'char_' [-Wwrite-strings]
LibusbTest.cpp:772:52: error: 'memset' was not declared in this scope
LibusbTest.cpp: In function 'std::shared_ptr
Actually, these are all issues with the C library funcitons, (as well as the exception class). Looks like the microsoft compiler allows construction of an exception with a string parameter where it probably shouldn't be ...breaking compatibility. No C++11 related errors there! (whew!)
As for the memset errors, I'm not sure why I never got an error on that. I suspect it was included as part of <wchar.h>. I've changed all references to use std::fill instead.
The strlen/strcpy methods should be in
I may soon have some Mac hardware to test this out on so I can support this better.
You can also install virtualbox and create a virtual machine with Ubuntu (or anther GNU/Linux system) inside.
Apple uses LLVM/clang instead of GCC. So you may find differences.
Great, now the compiling issue is gone. But how to build the library itself? Could you provide a Makefile?
mymacmini:LibusbTest xiaofanc$ g++-4.7 -std=c++11 -I../headers LibusbTest.cpp -o LibusbTest LibusbTest.cpp: In function 'int main(int, char*)': LibusbTest.cpp:479:82: warning: deprecated conversion from string constant to 'char' [-Wwrite-strings] LibusbTest.cpp:623:84: warning: deprecated conversion from string constant to 'char_' [-Wwrite-strings] LibusbTest.cpp:766:84: warning: deprecated conversion from string constant to 'char_' [-Wwrite-strings] Undefined symbols for architecture x86_64: "LibUSB::Configuration::SetAsActive()", referenced from: _main in ccNJ1QG4.o "LibUSB::IsochronousTransfer::setNumPackets(int)", referenced from: _main in ccNJ1QG4.o "LibUSB::Device::SerialString()", referenced from: _main in ccNJ1QG4.o ...
...and here I was thinking that the library was already compiled! :-)
I'll need a mac for product testing anyway, I should be able to test under every OS w/one machine then.