그래서 Visual Studio 2017을 사용하여 Linux 프로젝트를 만들려고합니다. 나는 빈 리눅스 프로젝트 (프로젝트 템플릿)로 시작했으며 지금까지 모든 것이 정상입니다.
그러나 내가 가지고 있다면
// Create a new thread for the connection to avoid clutter
std::thread newConnectionHandler(connectionHandler, iNewConnection);
newConnectionHandler.detach();
내 코드에서는 컴파일되지 않습니다. 다음과 같은 오류가 발생합니다.
Error E0020 identifier "__float128" is undefined
Error In function `std::thread::thread<void(&)(int), int&>(void(&)(int), int&)':
Error undefined reference to `pthread_create'
Error ld returned 1 exit status
그러나 내가 내용을 언급하자마자 std::thread
컴파일됩니다.
지금까지 시도한 내용은 다음과 같습니다.
-pthread -lpthread
또는 그냥-pthread
-pthread -lpthread
또는 그냥-pthread
thread
물론 변경 사항을 여러 번 변형했지만 항상 같은 오류가 발생합니다.
그리고 내 포함은 다음과 같습니다
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <thread>
편집 : 여기 또한 선언입니다 connectionHandler
:
void connectionHandler(int iConnection)
그리고 전달할 때 iNewConnection
데이터 유형은입니다 int
.
넣어 -pthread
에 옵션을 Linker -> Command Line -> Additional Options
, 또한 개체 및 라이브러리 파일의 모든 후 링크 명령 행의 마지막이어야한다.
순서가 중요합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다