티스토리 뷰


이전에 개요에서 읽어보면 묵시적 링크와 명시적 링크가 되어있는데..

나의 성격상 명시적 링크로 라이브러리를 제공해줘야 속시원하다-_-

여튼 LoadLibrary를 통해서 직접 해보록 해야겠다..

테스트는 SensorMonitoring에서 하는 부분 중..

OnInitDialog에 때려 넣는 걸로 테스트 해보고자 한다..

그럼 일단 다시 위키피디아 페이지에서 import하는 부분...

C and C++

Make sure you include Example.lib file(assuming that Example.dll is generated) in the project (Add Existing Item option for Project!)before static linking. The file Example.lib is automatically generated by the compiler when compiling the DLL. Not executing the above statement would cause linking error as the linker would not know where to find the definition of AddNumbers. You also need to copy the DLL Example.dll to the location where the .exe file would be generated by the following code.

#include <windows.h>
#include <stdio.h>

// Import function that adds two numbers
extern "C" __declspec(dllimport) double AddNumbers(double a, double b);

int main(int argc, char **argv)
{
        double result = AddNumbers(1, 2);
        printf("The result was: %f\n", result);
        return 0;
}


이렇게 되어있다. 묵시적 링크인가보군..일단 해보자..

Project-Property-Linker-Input-Additional Dependencies에다가

Preprocessor.lib를 추가하고..

extern 선언 추가..


extern "C" __declspec(dllimport) int Smoothing(float* inputData , int dataSize , float* &smoothingData , int& resultSize , int smoothingType);


함수내부에다가 추가...


//TODO : 테스트용 삭제
 int testSize = 0;
 int res = -1;
 float* test;
 res = Smoothing(NULL , 3 , test , testSize , 0);


그리고 컴파일..에러는 안나는군...그럼 breakpoint걸어놓고 f5로 실행..

사용자 삽입 이미지
이 상태에서...
사용자 삽입 이미지

이렇게 바뀜! dll 함수 콜이 성공적으로 이루어졌다!

음....지금껏 dll을 어렵게 생각해왔는데 알고 보니 별거 아니군!

그럼 다음엔 명시적 콜을 해봐야겠다..
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함