3

Hello i want to use pcre on my visual studio 2015. i got all pcre libs (i compiled it) and i set pcre lib dir on Linker/ General/Additional library Dir and this is my source

#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");
}

when i want to compile this project, i get this errors

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   

What is the problem !!! ??

i put all libs into link / input /additional ... and this is new errors

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   
Elh48
  • 43
  • 8
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Apr 17 '16 at 17:51
  • You also Probably need to set the specific library name(s) you are using at Linker->Input->Additional dependencies – Biruk Abebe Apr 17 '16 at 17:52
  • 1
    i did it.. 10 errors !!!!!!!!!!! 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 – Elh48 Apr 17 '16 at 18:11

2 Answers2

2

So, I assume you compiled it with BUILD_SHARED_LIBS=OFF option by default. Then you need to add PCRE_STATIC to preprocessor definitions of your app. With this define pcrecpp::RE class won't have __declspec(dllimport) in front of it, thus not trying to find an import library, which you don't have, because all the code is in a static library.

AlexStepanov
  • 451
  • 3
  • 13
  • 1
    IMHO this is a bug in the pcre CMAKE configuration, when CMAKE builds the Visual Studio project files, it should generate this token definition in the vcxproj files it generates for the build. I have this same problem and am looking at it. I recall I hacked through it to get the x64 version to build, now I'm doing it again for win32. In my case I have 5 projects building and 5 failing. 2 of the 5 are unit tests so I assume those are missing PCRE_STATIC in their build configuraitons. – Ross Youngblood Mar 14 '22 at 15:16
1

you should down the pcre-8.43-1 versin from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ here is the cc or cpp which has it realize。

350740378
  • 11
  • 1