How do you add your own code to the Astra SDK?

I downloaded the Astra SDK for mac and was going through the tutorials for HelloWorld. But when I run g++ main.cpp, it tells me:

main.cpp:8:10: fatal error: ‘astra/astra.hpp’ file not found

Where should I be putting this file for the Hello World? Are there any issues with this code?

Here is my code so far
#include < astra/astra.hpp> //ignore space after the < it won’t appear without the space here
#include < cstdio>
#include < iostream>
using namespace std;

int main(int argc, char** argv)
    astra::initialize(); //initialize ASTRA
    //connecting to the Astra
        //talking to the Astra sensor, connecting to the first available Astra sensor
        astra::StreamSet streamset;
        //access the stream of the Astra
        astra::StreamReader reader = streamSet.create_reader();
        //start the depth stream using StreamReader, the depth stream gives of anything the camera sees in pixels<astra::DepthStream>().start();
        //grabs a frame from the StreamReader
        astra::Frame frame = reader.get_latest_frame();
        //gets the depth frame data from the frame
        const auto depthFrame = frame.get<astra::DepthFrame>();
        //print info from the frame
        const int frameIndex = depthFrame.frame_index();
        const short pixelValue =[0];
        << "Depth frameIndex: " << frameIndex
        << " pixelValue " << pixelValue
        << endl
        << endl
    astra::terminate(); //terminate Astra
    cout << "hit enter to to exit program" << endl;
    return 0;

You need to make sure you set up your development environment correctly and also use the right includes.

#include <astra/astra.hpp> will tell the compiler to look in the system include path for your include files - which is unlikely to be where they are located by default

#include “astra/astra.hpp” would look for then as sub-folders of your current project on the other hand - which may be a better place to start.

Search Path (The C Preprocessor) has a good explanation of this.


1 Like

Where should I put the the file then? Where can I find the procedure to run this file properly? So far, I wasn’t able to find resources that would show the exact directions.

Ahh I see… I think I have to add a -i tag when I type g++ main.cpp -i but I’m getting other problems.