After I had finished an assigment, in which one had to implement a Win32 window, I wanted to export my functions to a dll.
Surprisingly the linker complains about unreferenced links, altough
- __declspec(dllexport) / __declspec(dllimport) is defined and used correctly (or as I am used to from C++).
- the library is correctly specified to the linker.
- the functions are visible within dependency walker.
The linker always complains (in german):
error LNK2019: Verweis auf nicht aufgel÷stes externes Symbol ""__declspec(dllimport) struct cw_Window * __cdecl createWindow(char *,unsigned short,unsigned short)" (__imp_?createWindow@@YAPEAUcw_Window@@PEADGG@Z)" in Funktion "main". C:\Users\jkirs\Desktop\Workspace\MSVC2015_x86_64-release\Unit.MSVC2015-x86-64.88a6cdd3\intermediate.Unit.exe : fatal error LNK1120: 1 nicht aufgel÷ste Externe
My functions prototypes are defined as following:
typedef struct cw_Window cw_Window_t;
typedef struct cw_Event cw_Event_t;
API cw_Window_t* createWindow(char* pTitle, uint16_t nWidth, uint16_t nHeight);
API void destroyWindow(cw_Window_t* pWindow);
API void pollEvent(cw_Window_t* pWindow, cw_Event_t* pEvent);
where as "API" is defined as following:
#ifdef _MSC_VER
#ifdef CW_EXPORT
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif
#else
#define API // TODO
#endif
I tried to add 'extern "C" to the 'API' definition as well, without a result, but complaining about the string literal 'C'.
Has anyone come across this issue himself yet and can point me towards the right direction?
If it matters: I am uinsg Visual Studio C++ 2015 (MSVC_x86_64); my header files end with '.h' and source files end with '.c'.
EDIT: The lib is supposed to be used in C code again.