I have 2 projects, RoofExp and testapp, the RoofExp is a DLL project which is written by C, the testapp is a win32 console project to test the RoofExp.dll. My code is listed below:
roofexp.h
#ifndef ROOF_EXP_PARSER_H
#define ROOF_EXP_PARSER_H
#ifdef ROOF_EXP_API
#else
#define ROOF_EXP_API __declspec(dllimport)
#endif
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
#define MAX_PARAS 16
enum ParaType
{
PARA_NUMBER = 1,
PARA_STRING
};
typedef struct _VARIABLE_INFO
{
char VarName[MAX_PATH];
struct _VARIABLE_INFO *next;
}VARIABLE_INFO, *PVARIABLE_INFO;
typedef struct _FUNCTION_INFO
{
char FuncName[MAX_PATH];
int FuncParas;
enum ParaType FuncParaType;
int FuncParaList[MAX_PARAS];
struct _FUNCTION_INFO *next;
}FUNCTION_INFO, *PFUNCTION_INFO;
ROOF_EXP_API void __cdecl ParserUninitialize();
ROOF_EXP_API int __cdecl ParserInitialize(PVARIABLE_INFO pVarList, PFUNCTION_INFO pFuncList);
ROOF_EXP_API int __cdecl ParserExecute(char *filename, int *errcnt, char *errmsg, int bufflen, void *fptr);
#define ERROR_PARSER_BASE 1024
#define ERROR_PARSER_SUCCESS 0x00
#define ERROR_PARSER_BAD_PARAMETERS ERROR_PARSER_BASE-1
#define ERROR_PARSER_FILE_NOT_FOUND ERROR_PARSER_BASE-2
#define ERROR_PARSER_FAILED_INIT ERROR_PARSER_BASE-3
#endif
testapp.cpp
int _tmain(int argc, _TCHAR* argv[])
{
char szFileName[MAX_PATH];
int nRetCode = 0;
ParserExecute(szFileName, &nRetCode, szFilePath, 1024, NULL);
return 0;
}
The RoofExp project can build successfully, When I build the testapp project, I got the following error message:
error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ParserExecute(char *,int *,char *,int,void *)
I googled for a long time and cannot resolve my problem. Can someone tell me what's wrong with my code and how to resolve it?