나는 zip 파일에서 소스 코드를 the website에 압축 해제하고 Code :: Blocks의 'include'폴더에 넣었지만 제공된 'hello.cpp'예제는 컴파일 할 수 없습니다.TinyThread ++를 제작해야합니까?
(
#include <iostream>
#include <tinythread.h>
using namespace std;
using namespace tthread;
// This is the child thread function
void HelloThread(void * aArg)
{
cout << "Hello world!" << endl;
}
// This is the main program (i.e. the main thread)
int main()
{
// Start the child thread
thread t(HelloThread, 0);
// Wait for the thread to finish
t.join();
}
그리고 이들은 다음과 같은 오류가 있습니다 :) 참고로 : ++
|41|undefined reference to `tthread::thread::thread(void (*)(void*), void*)'|
|44|undefined reference to `tthread::thread::join()'|
|44|undefined reference to `tthread::thread::~thread()'|
|44|undefined reference to `tthread::thread::~thread()'|
같은 일이 wxDev-C와 함께 발생합니다. 나는 무엇인가 놓치고 있는가? 내가 도서관이나 아무것도 만들지 않아도 돼? 그렇다면 어떻게?
대부분의 경우 라이브러리에 링크해야합니다. 이 오류에 대한 좋은 참조입니다 : http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix – chris
@chris 이것이 많은 최근의 오류에 대해 많은 것을 * 들었지만, 어떻게 라이브러리를 연결할 수 있습니까? 너 또는 다른 누군가가 나에게 설명해 줄 수 있니? : O – Mutoh
여기서는 적용되지 않지만 IDE를 사용하는 경우 일반적으로 링커 프로젝트 설정으로 이동하여 라이브러리를 추가 할 수 있습니다. MSVC는'#pragma comment (lib, "nameoflibrary.lib")'를 할 수있게 해주 며, 커맨드 라인에서는'-llibraryname'을 사용합니다. – chris