I build my DLL in debug mode, for window x86 system. Here is it's code
#include "pch.h"
#include <windows.h>
#include <iostream>
//I want my client app can use function nhan_2 and nhan_4
extern "C" __declspec(dllexport) int nhan_2(int a) {
return a * 2;
}
extern "C" __declspec(dllexport) int nhan_4(int a) {
return a * 4;
}
The output DLL was called Dll.dll, The output lib was called Dll.lib. Both was put in "D:\OLD C DRIVE\source\repos\Dll\Debug".
Then I created another project in debug mode, window x86 system. Here is it's code:
#include<iostream>
using namespace std;
#pragma comment (lib, "Dll.lib")
int main() {
int b = nhan_2(3);
cout << "b equal: " << b << endl;
}
Visual studio keep saying that identifier "nhan_2" is undefined and not found, even though I already config my project properties as:
- VC++ Directories->Include Directories: D:\OLD C DRIVE\source\repos\Dll\Debug
- VC++ Directories->External Include Directories: D:\OLD C DRIVE\source\repos\Dll\Debug
- VC++ Directories->Library Directories: D:\OLD C DRIVE\source\repos\Dll\Debug
- C/C++-> General->Additional Include Directories: D:\OLD C DRIVE\source\repos\Dll\Debug
- Linker -> General->Additional Library Directories: D:\OLD C DRIVE\source\repos\Dll\Debug
- Linker -> Input-> Additional Dependencies: Dll.lib
- Linker -> System -> SubSytem: Console
- Build Events -> Post-Build Event-> Command Line: xcopy /y /d "D:\OLD C DRIVE\source\repos\Dll\Debug\Dll.dll" "$(OutDir)"
Can some one help me use my DLL ?