TL;DR Can someone provide me a sample compile code for a pixy C++ script. I can’t seem to link pixy.h to my script
Long version:
I’ve asked this on a few other forums and haven’t gotten a great answer yet so I figured I should have asked here first and so now I am.
I have been trying to connect the Pixy Cam to a raspberry pi and am using C++ to allow the two to communicate. However, trying to write scripts for them doesn’t seem to work for me, even though my basic knowledge tells me it should be working so I’m assuming I’m missing something obvious.
Here is the simplest code I wrote that should work, as, if I understand headers correctly, I can call functions from any of the header files as if I were calling a function within the script itself, yes?
This script should just establish a connection with the camera, however the compiler still tells me that the function is undefined.
#include "stdio.h"
#include "stddef.h"
#include "stdint.h"
#include "unistd.h"
#include "pixy.h"
#include "pixydefs.h"
int main(int argc, char* argv[])
{
pixy_init();
}
I am using g++ to compile it using the following (shortened directory files to save space)
g++ code.cpp -oCode -I/"folder including libusb-1.0 and pixy.h"
So what am I missing? Everything I’ve learned so far says that this should work?
Do I have to include
-Llibusb
and whatever the relevant one for pixy.h is to the g++ command to link libraries? I’ve seen some people adding the -libusb to the end of it, however I haven’t been able to find what that does.