1. dll,so파일을 둘다 load하기 위해 Instance는 Void 포인터로 선언
void* m_dll;
2. 전처리를 이용하여 윈도우와 리눅스를 구분하는 define을 만들거나 이용함
typedef char* (*Export_Function)(char *, int);
Export_Function Ex_Fun;
#ifdef Window
m_dll = ::LoadLibrary(dll경로);
if (m_dll)
{
Ex_Fun = (Export_Function)::GetProcAddress((HINSTANCE)m_dll, "Export_FunctionData"); // 라이브러리에 있는 export 함수명 Export_FunctionData
}
#else 리눅스
m_dll = dlopen(dll경로, RTLD_NOW);
if (m_dll)
{
Ex_Fun = (Export_Function)dlsym(m_dll, "Export_FunctionData");
}
#endif
3. dlopen vs loadlibrary Include 헤더가 다름
#ifndef Window // 리눅스일때
#include <dlfcn.h>
#endif
undefined reference to 'dlopen' 리눅스 빌드 에러 (0) | 2021.01.08 |
---|---|
Visual Studio 환경변수와 같은 Path설정 (0) | 2020.11.25 |
[C,C++] 디버깅 (브레이크포인트)중단점 적중 문제 (0) | 2019.11.19 |
[C++] iterator 반복자 [vector 활용 예제] (0) | 2019.11.13 |
[C++] pair, make_pair [예제 소스] (0) | 2019.11.12 |
댓글 영역