<< return to Pixycam.com

Notes on building libpixyusb with Visual Studio on Windows

If your preferred platform for programming is Windows you may be interested in having a Visual Studio compatible version of libpixyusb. I will offer a few tricks for doing this.

libpixyusb as supplied has a dependency on some of the boost libraries. These are a pain to use on Windows, and everything that is required is contained in the C++ standard libraries. So go through and remove the boost includes and replace them with , and as appropriate. You will need to change namespace prefixes from boost:: to std::. You will find several places where usleep is used. On a non-realtime system like Linux or Windows, it is silly to use a sleep with microsecond precision, so substitute Sleep with the time scaled down by 1000. Use Sleep(1) for usleep(100).

There is also a dependency on libusb. You will want have an MSVC compatible version of this in a dll. You can find a prebuilt binary of this at libusb.info or you can build it from sources since they supply a Visual Studio project.

You will of course also have to set up include paths and place the appropriate source in the library project. I found the fastest way to do this was to setup a solution that basically just called pixy_init(). This project should reference another library project with the libpixyusb code (I set this up as a static library). Then you build and let the compiler tell you what you are missing. Go find it and put it in the project.

The final thing is that debug.h pulls in stuff from Qt. Edit it and comment out the includes, the class definition and the bodies of the 3 macros. You will end up with 2 defines of DBG and 1 of DBGE that do nothing.

At this point you should be able to build and use it from Visual Studio projects.

Hello Robert,
Thanks for sharing :slight_smile:

Regarding the usleeps: these are “guaranteed greater than or equal to” in Linux, although microsecond accuracy may not be there, it’s usually within a few microseconds believe it or not (in most cases). I would tend to want to keep these close to original values. These were set with performance in mind, although adjusting them won’t harm anything, you might notice that you’re not getting 50 Hz out of your Pixy.

There is also this:

http://pabloaizpiri.com/2015/10/25/net-pixycam-library/

Edward