C + + Learning Note (iv)-Multithreaded enumeration CMake

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.