MINERVA/C_CPP 2021. 11. 26. 11:27
반응형

vcpkg에 대한 사용 예제를 메시지로 부탁하신 분이 있어서 정리를 하여 보았습니다

 

1) boost  다운로드

- 64 bit dynamic: vcpkg install boost:x64-windows 

- 64 bit static: vcpkg install boost:x64-windows-static

1.설치

2) boost 확인

- vcpkg list

2.설치 확인

3) boost를 visual studio에 연결(?)

3.연결

위에 설명이 된대로, boost라이브러리를 사용시, 별도의 include와 libraray path설정없이 이제 바로 사용가능함

 

4) boost를 활용한 예제

- 쓰레드를 생성하는 예제

#include <iostream>
#include <typeinfo>
#include <thread>
#include <boost/thread.hpp>

using namespace std;

void myTest() {
    
    thread::id t_id = this_thread::get_id();
    cout << "thread called: " << typeid(t_id).name() <<' '<< sizeof(t_id) << 'T:' << t_id << endl;
}

int main()
{
    //-- 
    cout << "thread calling" << endl;

    //-- 쓰레드 생성: 4개 T1~T4
    boost::thread workerThread1(myTest);
    boost::thread workerThread2(myTest);
    boost::thread workerThread3(myTest);
    boost::thread workerThread4(myTest);

    //-- 각 쓰레드 작업 완료 대기
    workerThread1.join();
    workerThread2.join();
    workerThread3.join();
    workerThread4.join();
    
    cout << "thread done" << endl;
}

 

실행디렉토리

- 개발 작업을 할때, 별도의 라이브러리와 관련된 작업을 할필요가 없다.(include, library path...)

그리고, 제일 좋은 점은 개발에 사용된 라이브리를 자동으로 실행파일 위치에 복사여준다는 부분이 최고로 편함.

(이제는, XCOPY ...어쩌구 하는 작업을 하지 않아도 된다. 만세!!!)

 

감사합니다.

 

반응형
posted by choiwonwoo
: