需要加上編譯選項:-lpthread
gcc thread.c -o thread -lpthread
如果所eclipse 開發
方法1:
eclipse
解決方法如下:
方法1:Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可
方法2: 點擊工程,右鍵 -> 屬性 -> C/C++ Build -> Builder Settings
把自動生成makefile 選項,去選。
打開 debug 文件夾下的 makefile
讓後自己手工在makefile 種添加編譯選項:
gcc -o "sockThreadClient" $(OBJS) $(USER_OBJS) $(LIBS) -lpthread
gcc thread.c -o thread -lpthread
如果所eclipse 開發
方法1:
eclipse
解決方法如下:
方法1:Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries
在Libraries(-l)中添加pthread即可
在Libraries search path(-L)中添加crypto即可
方法2: 點擊工程,右鍵 -> 屬性 -> C/C++ Build -> Builder Settings
把自動生成makefile 選項,去選。
打開 debug 文件夾下的 makefile
讓後自己手工在makefile 種添加編譯選項:
gcc -o "sockThreadClient" $(OBJS) $(USER_OBJS) $(LIBS) -lpthread