A Function Declared Dllimport May Not Be Defined !free! Today

// Inside MyLibrary.cpp (the DLL project) __declspec(dllexport) void MyFunction() { // This function is now part of the DLL's public interface. }

Do not mark inline functions or template instantiations with dllimport / dllexport . Let the linker handle them. a function declared dllimport may not be defined

// myheader.h __declspec(dllimport) void myFunction(); // Client sees this // Inside MyLibrary

// utils.cpp (inside the EXE project) #include "utils.h" void Helper() { ... } // ERROR: This EXE is not the DLL! // myheader

__declspec(dllimport) tells the compiler: "This function exists in a different DLL — do not generate code for it here; instead, generate a call via the import library."

: The same header is used for both the DLL and the client application, but the logic to switch between is failing. Static Data/Inline Definitions : Attempting to define a data member or an function that is also marked with 3. Technical Solution: The "Switching" Macro

// myheader.h #ifdef BUILDING_MYDLL #define MYDLL_API __declspec(dllexport) #else #define MYDLL_API __declspec(dllimport) #endif