I know this is answered before, but i could not resolve my issue even after applying lots of solutions available on stackoverflow. I have 2 source files main.cpp and util.cpp. and one header file main.hpp
#ifndef MAIN_HPP
#define MAIN_HPP
#include <iostream>
int driver = 0;
#endif
i am planning to use the driver variable in both files. and i do have a cmake file:
SET(Main_INCLUDE_DIR include)
SET(Main_SRC_DIR src)
INCLUDE_DIRECTORIES(${INCLUDE_DIRS}
${Main_INCLUDE_DIR}
)
ADD_EXECUTABLE(poc
${Main_SRC_DIR}/main.cpp
${Main_SRC_DIR}/util.cpp
${moc_srcs}
)
error:
CMakeFiles/src/util.cpp.o:(.bss+0x0): multiple definition of `driver'
CMakeFiles/src/main.cpp.o:(.bss+0x0): first defined here