当要建立线程等时,在Linux下,用文本编辑,在键入“g++ -lpthread”.......“可以把库pthread引入”,编译通过。现在想用eclipse,但是默认情况下,引入不了pthread。会报“undefined reference to phread_create”等错误。
解决方法:可以在project中好到properties
在里面的“Tool Settings”;里找到“GCC C++ Linker”。
在其中的“Libraries”上添加“pthread”,按“ok”,重新编译就可以了。