Greetings, I would like to break my code up into separate files however, when I attempt to compile with #include <sl/c_api/zed_interface.h> I get the following error. Is this an issue with the header guards or something? I’m using jetson nano and the most current sdk (3.8.2). Also this is the C API
CMakeFiles/Control_System.dir/mesh.c.o:(.rodata+0x0): multiple definition of `SL_VIDEO_SETTINGS_VALUE_AUTO’
CMakeFiles/Control_System.dir/main.c.o:(.rodata+0x0): first defined here
collect2: error: ld returned 1 exit status
My CMakeLists.txt looks like this. All I have done is included my additional files in ADD_EXECUTABLE and included the math library in target_link_libraries.
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(Control_System)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 OLD)
cmake_policy(SET CMP0015 OLD)
endif(COMMAND cmake_policy)
SET(EXECUTABLE_OUTPUT_PATH “.”)
find_package(CUDA ${ZED_CUDA_VERSION} REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
link_directories(${CUDA_LIBRARY_DIRS})
if (WIN32)
include_directories($ENV{ZED_SDK_ROOT_DIR}/include/)
link_directories($ENV{ZED_SDK_ROOT_DIR}/lib/)
else (WIN32)
include_directories(“/usr/local/zed/include/”)
link_directories(“/usr/local/zed/lib/”)
endif(WIN32)
ADD_EXECUTABLE(${PROJECT_NAME} main.c mesh.c mesh.h)
target_link_libraries(${PROJECT_NAME} sl_zed_c ${CUDA_CUDA_LIBRARY} ${CUDA_CUDART_LIBRARY} m)
Thank you.
Hi Josef,
When you compiled the c wrapper, did you run make install
? This will copy the headers and libraries into the ZED folder (see : https://www.stereolabs.com/docs/app-development/c/install/).
You can also take a look at our c tutorials to see what needs to be added in the CMakeLists ; https://github.com/stereolabs/zed-examples/blob/master/tutorials/tutorial%201%20-%20hello%20ZED/c/CMakeLists.txt.
Best,
Benjamin Vallon
Stereolabs Support
Thank you for the reply, yes I did run make install, this is the location in my jetson.
josef@jetson:/usr/local/zed/include/sl$ ls
Camera.hpp c_api
josef@jetson:/usr/local/zed/include/sl$ cd c_api/
josef@jetson:/usr/local/zed/include/sl/c_api$ ls
types_c.h zed_interface.h
josef@jetson:/usr/local/zed/include/sl/c_api$ pwd
/usr/local/zed/include/sl/c_api
josef@jetson:/usr/local/zed/include/sl/c_api$
Also this is my project layout.
josef@jetson:~/Control_System$ ls
build CMakeLists.txt init.c init.h main.c mesh.c mesh.h state.c state.h
As long as I only have the zed_interface.h in main everything works fine. Its when I attempt to include it in another one of those files. For example I would like to wrap the init code into functions in the init.c file and call them from main. However it if I include it like this.
#include <sl/c_api/zed_interface.h>
#include “init.h”
in my init.c file I get the error,
multiple definition of `SL_VIDEO_SETTINGS_VALUE_AUTO’
I’m pretty sure that the correct #ifndef INIT_H_ #define INIT_H_ scheme would take care of stuff like that. I just don’t want to add it myself and break something 
I think I solved it.
After reading this post:
c - Multiple definition of const variables at header file - Stack Overflow
I added the static modifier to this const located in types_c.h
static const int SL_VIDEO_SETTINGS_VALUE_AUTO = -1;
This solved the linker error, everything works fine now. I just have to figure out why this worked next. 