I've started learning C++ over some other high-level languages and it starts driving me crazy.
When I compile a program like that:
gcc $FILE_TO_COMPILE -o $OUTPUT -lstdc++
All it works. CLion comes with its own cmake, so it executes the following command which also works:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/username/studies/cmake-build-debug --target simple_example -- -j 4
but when I compile like that:
gcc -O2 -static -v $FILE_TO_COMPILE -o $OUTPUT
I get a lot of verbose output which ends up with:
ld: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)
OK, from verbose I can understand that I haven't attached proper lib to compile, but I'd love to debug which part of my code uses this lib. Here's a gist with the code to reproduce the problem:https://gist.github.com/Dominos/226b651a508cb48ce7272f7dd3e447e2
Can anyone tell me what's the proper way to debug problems like this? I don't need an answer what's the problem, I'd prefer how to find out this.