Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What about the compilation error when using the thread class in C++

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "C++ using thread classes when compiling errors how to do", the content is easy to understand, well-organized, I hope it can help you solve their doubts, the following let the editor lead you to study and learn about "C++ thread classes when compiling errors when how to do" this article.

/ tmp/ccM2tvqF.o: In function `main':

Thread_c.c: (.text + 0x1f): undefined reference to `pthread_create'

Thread_c.c: (.text + 0x52): undefined reference to `pthread_create'

Thread_c.c: (.text + 0x7d): undefined reference to `pthread_join'

Thread_c.c: (.text + 0xa9): undefined reference to `pthread_join'

Collect2: ld returned 1 exit status

After checking for a long time, I thought there was a problem with the code, and finally I found out that because the pthread library is not the default library of the Linux system, we need to use the library libpthread.a when connecting, so when we use pthread_create to create a thread, we should add the-lpthread parameter: gcc test_thread.c-lpthread-o test_thread. After adding this, the compilation is successful!

These are all the contents of this article entitled "what to do when compiling errors when using thread classes in C++". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report