又回到了ubuntu,环境配置自然费了点功夫,然后写个多线程一堆error,解决到最后就剩undefined reference to "pthread_create",于是百度,是没有链接libpthread.so。长期以来,从来没有为这种问题费过神,这在windows下自然有visual studio帮我搞定了。最后,解决方法就是 -pthread
g++ -std=c++11 -o test thread_pool.h primer.h primer.cpp -lpthread
博主在Ubuntu环境下配置开发环境时遇到困难,特别是多线程编程出现错误undefined reference to pthread_create。问题根源在于未链接libpthread.so库。在Windows下,Visual Studio通常会自动处理这类问题。解决方案是在g++编译命令中添加-pthread选项,成功解决了链接问题。
又回到了ubuntu,环境配置自然费了点功夫,然后写个多线程一堆error,解决到最后就剩undefined reference to "pthread_create",于是百度,是没有链接libpthread.so。长期以来,从来没有为这种问题费过神,这在windows下自然有visual studio帮我搞定了。最后,解决方法就是 -pthread
g++ -std=c++11 -o test thread_pool.h primer.h primer.cpp -lpthread

被折叠的 条评论
为什么被折叠?