Answer the question
In order to leave comments, you need to log in
Why is the DLL not being connected to the Visual Studio C++ project?
Hello, I created a DLL library according to the manual, and connected the files to the project using it, but #include doesn’t see them, it says it can’t open the file
. What’s the problem?
Answer the question
In order to leave comments, you need to log in
So, let's say we have a dynamic library MyDLL.dll with the following code
#include <windows.h>
int __declspec(dllexport) MyDLLSqr(const int n) {
return n*n;
}
extern "C" bool __declspec(dllexport)
DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
return true;
}
#include <iostream>
extern "C" void __declspec(dllimport) MyDLLSqr (const int);
int main() {
std::cout<< MyDLLSqr(4); // 4
}
#pragma once
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
extern "C" void DLL_EXPORT MyDLLSqr (const int);
#include
and linking are different things.
include is the path to the header files (*.h) - is specified in the project properties
. Linking is the path to the lib file - also in the properties, but in a different way.
specify the correct path to DLL.h
It is likely that the file is either not readable or is in a different location
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question