Having trouble running code. Message reads "This file does not belong to any project target..."
I am new to using CLion and am trying to build my first project. I have two source files (main.cpp and Hero.cpp) and a header for Hero. At the top of Hero.cpp there is a yellow banner that reads "This file does not belong to any project target; code insight features might not work properly." When I try to run my code, I get:
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
Undefined symbols for architecture x86_64:
"Hero::GetStrength()", referenced from:
PrintHero(Hero) in main.cpp.o
"Hero::GetHitpoints()", referenced from:
PrintHero(Hero) in main.cpp.o
"Hero::GetName()", referenced from:
PrintHero(Hero) in main.cpp.o
"Hero::Hero(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int)", 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[3]: *** [untitled] Error 1
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
make: *** [untitled] Error 2
Any idea what is going on here? Thanks in advance.
Please sign in to leave a comment.
I was able to figure out the problem. I updated the default
add_executable line in CMakeLists.txt by adding my cpp file names to it.