最近在研究涛思数据库,使用调库函数的方式实现sql的指令读写,但涛思的头文件中要用到的函数都是这样定义的:
#ifdef TD_GO_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif
DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
DLL_EXPORT char *taos_get_server_info(TAOS *taos);
DLL_EXPORT char *taos_get_client_info();
这样看着是从dll导出的函数,我直接调用会报错无法解析的外部符号
taos_options(TSDB_OPTION_TIMEZONE,"CST");
TAOS* taos = taos_connect(m_taosip.c_str(),m_csUser.c_str(),m_csPasswd.c_str(),m_csDBname.c_str(),0);
char * info = taos_get_server_info(taos);
info = taos_get_client_info();
错误 8 error LNK1120: 4 个无法解析的外部命令
错误 6 error LNK2001: 无法解析的外部符号 _taos_connect
错误 5 error LNK2001: 无法解析的外部符号 _taos_get_server_info
错误 4 error LNK2001: 无法解析的外部符号 _taos_get_client_info
错误 7 error LNK2001: 无法解析的外部符号 _taos_options
在网上查了有关__declspec(dllexport)和__declspec(dllimport)的使用,但也会报错taos重定义之类的问题
#ifndef DLL_H_
#define DLL_H_
#ifdef DLLProvider
#define DLL_EXPORT_IMPORT __declspec(dllexport)
#else
#define DLL_EXPORT_IMPORT __declspec(dllimport)
#endif
DLL_EXPORT_IMPORT int taos_init();
#endif
错误 1 error C2375: “taos_init”: 重定义;不同的链接
4 IntelliSense: 重新声明无法将 dllexport/dllimport 添加到 "taos_init"
所以想请教下,这种在头文件里用了__declspec(dllexport)从dll输出的函数,应该怎么实现正常调用?