Libargus example program compile and link help

Hey there, I’ve been working with the examples in MMAPI and have even had success at adding my own program into the argus/samples and modifying the CMakeLists.txt. However, I would like to be able to write my own example program that uses libargus without all the included overhead of the MMAPI with all it’s samples and nested makefiles.

-Projects
    -main.cpp
    -Makefile
    -jetson_multimedia_api/

I would like to run a really simple sample program that simply uses the API to create a camera provider object, say hello and exit without crashing.

#include <stdio.h>
#include <Argus/Argus.h>

using namespace Argus;
int main() {
    UniqueObj<CameraProvider> cameraProvider(CameraProvider::create());
    ICameraProvider* iCameraProvider = interface_cast<ICameraProvider>(cameraProvider);
    
    if(!iCameraProvider) 
        printf("Failed to generate camera provider\n");
        return 1;

    printf("Hello world\n");
    return 0;
}

I’ve looked into the gnu make docs about adding directories for the preprocessor to check but I’m getting stuck on figuring out how to apply this to using Argus. I’ve examined the Makefiles and CMakeLists but I haven’t been able to discern what I’m missing. The part that I’m clearly stumped by is how to make the compilation work with

#include <Argus/Argus.h>

What I’m asking for is help writing a single Makefile to compile and link my example program. Any help and guidance would be greatly appreciated.

1 Like

Did some more reading and found some answers that lead to a successful compile and link.

Seems I was missing a second step in the linking process. I needed to add the path for the API headers with the following flag:

#-I path/to/api/headers
-I jetson_multimedia_api/argus/include

This allowed me to compile without an error because Argus/Argus.h could not be found

Next I needed to find where the static libraries are located on the system. This required the most work and I was able to find them by reading the jetson_multimedia_api/Rules.mk. At the bottom LDFLAGS is declared and says where to find the libraries in /usr/lib/aarch64-linux-gnu/tegra which you can link through the following:

-L /usr/lib/aarch64-linux-gnu/tegra

Finally I needed to link the library by name. Searching through the tegra directory mentioned above, I found libnvargus. Link with the flag:

-lnvargus

With these flags, I was able to build and link without having my workspace set up inside the nested directories.

2 Likes