我有客户端服务器代码。LinServer.cpp使用pthread持续监听客户端。我创建了make文件来编译所有的togather:
all: LinServer LinClient
LinServer:
g++ LinServer.cpp -o LinServer -pthread
LinClient:
g++ LinClient.cpp -o LinClient -pthread我也尝试过-lpthread,但出现了相同的错误:
LinServer.cpp:(.text+0x29b): undefined reference to `pthread_create'
LinServer.cpp:(.text+0x2a7): undefined reference to `pthread_detach'
collect2: error: ld returned 1 exit status
make: *** [LinServer] Error 1你知道问题出在哪里吗?
发布于 2013-06-24 05:21:31
您应该使用-lpthread,而不是-pthread。
https://stackoverflow.com/questions/17264984
复制相似问题