gpt4 book ai didi

c++ - pcre visual studio 上未解析的外部符号

转载 作者:行者123 更新时间:2023-12-05 04:13:48 25 4
gpt4 key购买 nike

你好,我想在我的 visual studio 2015 上使用 pcre。我得到了所有 pcre 库(我编译了它)并且我在 Linker/General/Additional library Dir 上设置了 pcre lib 目录这是我的来源

#include <iostream>
#include <string>
#include <stdlib.h>
#include <map>
#include "pcrecpp.h"

using namespace std;
using namespace pcrecpp;

void main()
{


RE_Options Regex_Options;

// Set options
Regex_Options.set_caseless(true);
Regex_Options.set_multiline(true);
Regex_Options.set_dotall(true);

RE Regex("h.*o", Regex_Options);

Regex.FullMatch("hello");


system("pause");
}

当我想编译这个项目时,我得到了这个错误

Severity    Code    Description Project File    Line    Suppression State
Error LNK2019 unresolved external symbol "public: bool __thiscall pcrecpp::RE::FullMatch(class pcrecpp::StringPiece const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &)const " (?FullMatch@RE@pcrecpp@@QBE_NABVStringPiece@2@ABVArg@2@111111111111111@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "public: __thiscall pcrecpp::RE::~RE(void)" (??1RE@pcrecpp@@QAE@XZ) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "private: void __thiscall pcrecpp::RE::Init(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class pcrecpp::RE_Options const *)" (?Init@RE@pcrecpp@@AAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBVRE_Options@2@@Z) referenced in function "public: __thiscall pcrecpp::RE::RE(char const *,class pcrecpp::RE_Options const &)" (??0RE@pcrecpp@@QAE@PBDABVRE_Options@1@@Z) TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2001 unresolved external symbol "public: static class pcrecpp::Arg pcrecpp::RE::no_arg" (?no_arg@RE@pcrecpp@@2VArg@2@A) TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK1120 4 unresolved externals TestProg D:\Visual Studio Projects\TestProg\Debug\TestProg.exe 1

有什么问题!!! ??

我将所有库放入链接/输入/附加...这是新的错误

Severity    Code    Description Project File    Line    Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall pcrecpp::RE::RE(char const *,class pcrecpp::RE_Options const &)" (__imp_??0RE@pcrecpp@@QAE@PBDABVRE_Options@1@@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall pcrecpp::StringPiece::StringPiece(char const *)" (__imp_??0StringPiece@pcrecpp@@QAE@PBD@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall pcrecpp::RE_Options::RE_Options(void)" (__imp_??0RE_Options@pcrecpp@@QAE@XZ) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class pcrecpp::RE_Options & __thiscall pcrecpp::RE_Options::set_caseless(bool)" (__imp_?set_caseless@RE_Options@pcrecpp@@QAEAAV12@_N@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class pcrecpp::RE_Options & __thiscall pcrecpp::RE_Options::set_multiline(bool)" (__imp_?set_multiline@RE_Options@pcrecpp@@QAEAAV12@_N@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class pcrecpp::RE_Options & __thiscall pcrecpp::RE_Options::set_dotall(bool)" (__imp_?set_dotall@RE_Options@pcrecpp@@QAEAAV12@_N@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall pcrecpp::RE::~RE(void)" (__imp_??1RE@pcrecpp@@QAE@XZ) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall pcrecpp::RE::FullMatch(class pcrecpp::StringPiece const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &,class pcrecpp::Arg const &)const " (__imp_?FullMatch@RE@pcrecpp@@QBE_NABVStringPiece@2@ABVArg@2@111111111111111@Z) referenced in function _main TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK2001 unresolved external symbol "__declspec(dllimport) public: static class pcrecpp::Arg pcrecpp::RE::no_arg" (__imp_?no_arg@RE@pcrecpp@@2VArg@2@A) TestProg D:\Visual Studio Projects\TestProg\TestProg\Source.obj 1
Error LNK1120 9 unresolved externals TestProg D:\Visual Studio Projects\TestProg\Debug\TestProg.exe 1

最佳答案

因此,我假设您默认使用 BUILD_SHARED_LIBS=OFF 选项编译它。然后您需要将 PCRE_STATIC 添加到应用程序的预处理器定义中。使用此定义 pcrecpp::RE 类将不会在其前面有 __declspec(dllimport),因此不会尝试查找您没有的导入库,因为所有代码都在静态库中。

关于c++ - pcre visual studio 上未解析的外部符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36680032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com