Hi, I’ve installed the SDK and have managed to run of the bundled sample files. However, when following the tutorial in the Astra book, I get a bunch of errors…
My code is as follows:
#include <astra/astra.hpp>
#include <astra_core/astra_core.hpp>
#include <cstdio>
#include <iostream>
int main(int argc, char** argv)
{
astra::initialize();
astra::StreamSet streamSet;
astra::StreamReader reader = streamSet.create_reader();
reader.stream<astra::DepthStream>().start();
astra::Frame frame = reader.get_latest_frame();
const auto depthFrame = frame.get<astra::DepthFrame>();
const int frameIndex = depthFrame.frame_index();
const short pixelValue = depthFrame.data()[0];
std::cout << std::endl
<< "Depth frameIndex: " << frameIndex
<< " pixelValue: " << pixelValue
<< std::endl
<< std::endl;
astra::terminate();
std::cout << "hit enter to exit program" << std::endl;
std::cin.get();
return 0;
}
My g++ compile command is:
g++ -std=c++11 -I "/home/roberto/Documents/AstraSDK/include/" -L "/home/roberto/Documents/AstraSDK/lib/" -lastra -lastra_core -lastra_core_api -o main main.cpp
The errors I get are:
/tmp/ccNhFj18.o: In function `astra::Frame::FrameRef::~FrameRef()': main.cpp:(.text._ZN5astra5Frame8FrameRefD2Ev[_ZN5astra5Frame8FrameRefD5Ev]+0x2c): undefined reference to `astra_reader_close_frame' /tmp/ccNhFj18.o: In function `astra::StreamReader::get_latest_frame(int)': main.cpp:(.text._ZN5astra12StreamReader16get_latest_frameEi[_ZN5astra12StreamReader16get_latest_frameEi]+0x91): undefined reference to `astra_reader_open_frame' /tmp/ccNhFj18.o: In function `astra::StreamReader::ReaderRef::~ReaderRef()': main.cpp:(.text._ZN5astra12StreamReader9ReaderRefD2Ev[_ZN5astra12StreamReader9ReaderRefD5Ev]+0x34): undefined reference to `astra_reader_destroy' /tmp/ccNhFj18.o: In function `astra::StreamReader::ReaderRef::ensure_callback_removed()': main.cpp:(.text._ZN5astra12StreamReader9ReaderRef23ensure_callback_removedEv[_ZN5astra12StreamReader9ReaderRef23ensure_callback_removedEv]+0x24): undefined reference to `astra_reader_unregister_frame_ready_callback' /tmp/ccNhFj18.o: In function `astra::StreamSet::StreamSetRef::connect()': main.cpp:(.text._ZN5astra9StreamSet12StreamSetRef7connectEv[_ZN5astra9StreamSet12StreamSetRef7connectEv]+0x3f): undefined reference to `astra_streamset_open' /tmp/ccNhFj18.o: In function `astra::StreamSet::StreamSetRef::~StreamSetRef()': main.cpp:(.text._ZN5astra9StreamSet12StreamSetRefD2Ev[_ZN5astra9StreamSet12StreamSetRefD5Ev]+0x28): undefined reference to `astra_streamset_close' /tmp/ccNhFj18.o: In function `astra::StreamSet::create_reader()': main.cpp:(.text._ZN5astra9StreamSet13create_readerEv[_ZN5astra9StreamSet13create_readerEv]+0x68): undefined reference to `astra_reader_create' /tmp/ccNhFj18.o: In function `astra::DataStream::DataStream(_astra_streamconnection*)': main.cpp:(.text._ZN5astra10DataStreamC2EP23_astra_streamconnection[_ZN5astra10DataStreamC5EP23_astra_streamconnection]+0x3a): undefined reference to `astra_stream_get_description' /tmp/ccNhFj18.o: In function `astra::DataStream::start()': main.cpp:(.text._ZN5astra10DataStream5startEv[_ZN5astra10DataStream5startEv]+0x5b): undefined reference to `astra_stream_start' /tmp/ccNhFj18.o: In function `astra::initialize()': main.cpp:(.text._ZN5astra10initializeEv[_ZN5astra10initializeEv]+0x5): undefined reference to `astra_initialize' /tmp/ccNhFj18.o: In function `astra::terminate()': main.cpp:(.text._ZN5astra9terminateEv[_ZN5astra9terminateEv]+0x5): undefined reference to `astra_terminate' /tmp/ccNhFj18.o: In function `astra::ImageFrame<short, 1>::ImageFrame(_astra_imageframe*, unsigned int)': main.cpp:(.text._ZN5astra10ImageFrameIsLi1EEC2EP17_astra_imageframej[_ZN5astra10ImageFrameIsLi1EEC5EP17_astra_imageframej]+0x5a): undefined reference to `astra_imageframe_get_metadata' main.cpp:(.text._ZN5astra10ImageFrameIsLi1EEC2EP17_astra_imageframej[_ZN5astra10ImageFrameIsLi1EEC5EP17_astra_imageframej]+0x8d): undefined reference to `astra_imageframe_get_frameindex' main.cpp:(.text._ZN5astra10ImageFrameIsLi1EEC2EP17_astra_imageframej[_ZN5astra10ImageFrameIsLi1EEC5EP17_astra_imageframej]+0xb3): undefined reference to `astra_imageframe_get_data_ptr' /tmp/ccNhFj18.o: In function `astra::DepthStream astra::StreamReader::stream<astra::DepthStream>(int)': main.cpp:(.text._ZN5astra12StreamReader6streamINS_11DepthStreamEEET_i[_ZN5astra12StreamReader6streamINS_11DepthStreamEEET_i]+0x96): undefined reference to `astra_reader_get_stream' /tmp/ccNhFj18.o: In function `astra::DepthFrame astra::ImageFrame<short, 1>::acquire<astra::DepthFrame>(_astra_reader_frame*, int)': main.cpp:(.text._ZN5astra10ImageFrameIsLi1EE7acquireINS_10DepthFrameEEET_P19_astra_reader_framei[_ZN5astra10ImageFrameIsLi1EE7acquireINS_10DepthFrameEEET_P19_astra_reader_framei]+0x3d): undefined reference to `astra_reader_get_imageframe' collect2: error: ld returned 1 exit status
Does anyone have any ideas? If I don’t call the astra functions, but maintain the include, it compiles correctly, so it smells like a linker problem for me.
In any case, thanks in advance for reading my first post!
Best,
Roberto