我有两个项目,RoofExp 和 testapp,RoofExp 是一个 C 语言编写的 DLL 项目,testapp 是一个 win32 控制台项目,用于测试 RoofExp.dll。我的代码如下:
屋顶exp.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
测试应用程序.cpp
int _tmain(int argc, _TCHAR* argv[])
{
char szFileName[MAX_PATH];
int nRetCode = 0;
ParserExecute(szFileName, &nRetCode, szFilePath, 1024, NULL);
return 0;
}
RoofExp 项目可以成功构建,当我构建 testapp 项目时,我收到以下错误消息:
error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ParserExecute(char *,int *,char *,int,void *)
我google了很长时间,无法解决我的问题。有人能告诉我我的代码有什么问题以及如何解决吗?