I have created a dll where I have declared some functions that accept struct as parameters along with source where I have these functions defined.
The library compiles without any issues but when I link it with my sample client program I get linker error 2019 for the functions and struct declared and defined in my library. Any advice would be much appreciated.
For declaring the structure so that it is available in the source file as well as the linking test app, I did as explained in the below link (one of the very few threads on the internet that answers how one should include struct in a DLL) Making a structure visible in both library and application - C
I have got the struct declared in a header file and included the header file in my library header file that has the declarations for my functions. I have a sample file with the same name which has both the structure header and the library header file included.
Unfortunately for me, I am still getting lnk2019 for the functions and the struct I have declared in my library.
My Library header:
#include "STRUCTURE.h"
#include "debug.h"
#ifdef LINKEDLISTDLL_EXPORTS
#define LINKEDLISTDLL_API __declspec(dllexport)
#else
#define LINKEDLISTDLL_API __declspec(dllimport)
#endif
LINKEDLISTDLL_API pEntry initialize(pEntry);
LINKEDLISTDLL_API pEntry InsertatHead(pEntry, pEntry);
LINKEDLISTDLL_API pEntry InsertatTail(pEntry, pEntry);
LINKEDLISTDLL_API pEntry RemoveatHead(pEntry);
LINKEDLISTDLL_API pEntry RemoveatTail(pEntry);
STRUCTURE.h:
#ifndef STRUCTURE_H
#define STRUCTURE_H
typedef struct List_Entry
{
struct List_Entry* FLink;
struct List_Entry* BLink;
}Entry, * pEntry;
#endif
pch.h:
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#include "STRUCTURE.h"
#include "debug.h"
#include "LINKEDLISTDLL.h"
#endif //PCH_H
Any advice on what I might be doing wrong here? My sample code has all these headers included and the lib file linked. The lib file builds without any issues. Any help will be much appreciated. Please let me know if any more details are required. Thanks in advance.