使用libconfig时显示LNK2019

时间:2019-05-07 22:15:31

标签: c++ lnk2019 unresolved-external libconfig

所以基本上我是在Visual Studio 2019 Windows 10上编写32位程序的。 我希望程序包含libconfig,但是每次编译它时,都会遇到“函数_main中引用的未解析的外部符号” 我编译并包含libconfig ++。lib作为附加依赖项(调试32位)。 我在谷歌上搜索了一段时间,但没有任何东西可以完全帮助我。 也许我的设置有问题,因为我在使用某些库时也会得到它们

LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall libconfig::Config::Config(void)" (__imp_??0Config@libconfig@@QAE@XZ) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: virtual __thiscall libconfig::Config::~Config(void)" (__imp_??1Config@libconfig@@UAE@XZ) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: void __thiscall libconfig::Config::readFile(char const *)" (__imp_?readFile@Config@libconfig@@QAEXPBD@Z) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall libconfig::Config::lookupValue(char const *,bool &)const " (__imp_?lookupValue@Config@libconfig@@QBE_NPBDAA_N@Z) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall libconfig::Config::lookupValue(char const *,int &)const " (__imp_?lookupValue@Config@libconfig@@QBE_NPBDAAH@Z) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall libconfig::Config::lookupValue(char const *,char const * &)const " (__imp_?lookupValue@Config@libconfig@@QBE_NPBDAAPBD@Z) referenced in function _main
LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall libconfig::Config::lookupValue(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)const " (__imp_?lookupValue@Config@libconfig@@QBE_NPBDAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
#include <libconfig/libconfig.h++>

bool logging = true;
bool debug = false;

int main(int argc, char* argv[])
{
libconfig::Config cfg;

const char* cfgFilePathC = "D:\\default.cfg";

cfg.readFile(cfgFilePathC);
std::string dumpName;
int threadPriority;
cfg.lookupValue("logging", logging);
cfg.lookupValue("debug", debug);
cfg.lookupValue("dumpName", dumpName);
cfg.lookupValue("threadPriority", threadPriority);

bool downloadCustomFile, startAfterDownload;
std::string downloadFromUrl, fileName;
cfg.lookupValue("downloadCustomFile", downloadCustomFile);
cfg.lookupValue("downloadFromUrl", downloadFromUrl);
cfg.lookupValue("fileName", fileName);
cfg.lookupValue("startAfterDownload", startAfterDownload);

std::stringhost, user, pass;
cfg.lookupValue("host", host);
cfg.lookupValue("user", user);
cfg.lookupValue("pass", pass);

0 个答案:

没有答案