[root@localhost cpp]# g++ test.cpp -o test
/tmp/ccss6u2f.o:在函数‘main’中:
test.cpp:(.text+0x64):对‘pthread_create’未定义的引用
collect2: 错误:ld 返回 1
原因:因为有pthread_create函数,这个类用到posix实现的线程了。
解决办法:
g++ -o test test.cpp -lpthread
这样就可以正常编译通过了
[root@localhost cpp]# g++ test.cpp -o test
/tmp/ccss6u2f.o:在函数‘main’中:
test.cpp:(.text+0x64):对‘pthread_create’未定义的引用
collect2: 错误:ld 返回 1
原因:因为有pthread_create函数,这个类用到posix实现的线程了。
解决办法:
g++ -o test test.cpp -lpthread
这样就可以正常编译通过了