I have a simple C++ project with following files
├── include
│ └── project_name
│ └── node.h
├── src
│ ├── main.cpp
│ └── node.cpp
├── test
└── CMakeLists.txt
and in CmakeLists.txt, I have
cmake_minimum_required(VERSION 3.15)
project(project_name)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# include files
include_directories(
include
)
# target
add_executable(
maple
src/node.cpp
src/main.cpp
)
As you see. it is very simple project but I was getting
[ 33%] Linking CXX executable maple
Undefined symbols for architecture x86_64:
"Node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::print()", referenced from:
_main in main.cpp.o
"Node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Node(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [maple] Error 1
make[1]: *** [CMakeFiles/project_name.dir/all] Error 2
make: *** [all] Error 2
The three questions I wanted to ask are
What do I need to change in CMakeLists.txt to fix the issue?
How can I check which C++ compiler is being used?
Is it actually being compiled with C++17? How can I check?
Thank you so much for your time