C + + Enumeration
The use of C++11 specifications in the multi-threading, and then compile the error, the noon various changes cmakelists did not fix, the afternoon brother introduced documents, CMake practice, referring to the seventh chapter, done.
Just add a word to the CMakeLists.txt:
Set (Cmake_cxx_flags ${cmake_cxx_flags} "-std=c++11-pthread")
At first, there was no-pthread to make, but when it was running, it collapsed, referring to the solution.
According to the discussion, the desktop Linux environment is OK, if it is an embedded cross-compilation environment, you also need to display add
Find_package (Threads)
What if I want to write a Raspberry Pi?
Doubt:
Try at noon Cmakelists is from the compiled through the orb_slam2, such as the next, then compile no problem, and run TUM_MONO,CPU use rate from less than 100% to the last can be higher than 200%, should be 3 threads are open to occupy so much bar, It's not clear why I can't get my own project.
1 # Check c++11 or c++0x support2 include (Checkcxxcompilerflag)3 Check_cxx_compiler_flag ("-std=c++11" compiler_supports_cxx11)4 Check_cxx_compiler_flag ("-std=c++0x" compiler_supports_cxx0x)5 if (compiler_supports_cxx11)6 set (cmake_cxx_flags "${cmake_cxx_flags}-std=c++11")7 ElseIf (compiler_supports_cxx0x)8 set (cmake_cxx_flags "${cmake_cxx_flags}-std=c++0x")9 Else ()Ten the message (fatal_error "The compiler ${cmake_cxx_compiler} has a no c++11 support. Use a different C + + compiler. ") Oneendif ()
C + + Learning Note (iv)-Multithreaded enumeration CMake