L.Allan
2007-12-10 18:54:22 UTC
I'm trying to get an MFC v6 project to link with the C Perl Compatible
Regular Expression (pcre) library, and encountering a link error about
unresolved references. Pcre seems mostly oriented to the unix/linux
world, and more or less unaware that Microsoft exists. There is a C++
"wrapper" but it seems mostly for having a regex object, which isn't
what I'm struggling with. Help appreciated.
I'm mostly ignorant about using the linker beyond using the ide.
extern "C" {
#include "pcre.h"
}
BOOL CPcreTestApp::InitInstance()
{
pcre *re = NULL;
const char* error;
int errorOffset;
char *subject = "Is the string red found in this string?";
int ovector[30];
int subject_length = strlen(subject);
const char* version = pcre_version();
re = pcre_compile("red.+this", 0, &error, &errorOffset, NULL);
int rc = pcre_exec(re, NULL, subject, subject_length, 0, 0, ovector,
30);
.... MFC code
}
The above compiles ok, but results in the following link errors:
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_exec
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_compile
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_version
The pcre library comes with several .def files, but the various
combinations I've tried don't help.
I've got pcre_vc6d.lib specified in the .dsp file, but it isn't able
to resolve. I've been able to get it to compile/link/run as a
"vanilla" C project with PcreTestConsole.c linking to
Debug\pcre_vc6d.lib, so building the library seems to work.
Do I need something like pcre_mfc.def and, if so, what would it
contain? Is there some parameter to the compiler or linker I need?
Should I build the pcre_vc6d.lib differently?
Here is a link to the vc6 project:
http://www.berbible.org/misc/PcreTest.zip
Regular Expression (pcre) library, and encountering a link error about
unresolved references. Pcre seems mostly oriented to the unix/linux
world, and more or less unaware that Microsoft exists. There is a C++
"wrapper" but it seems mostly for having a regex object, which isn't
what I'm struggling with. Help appreciated.
I'm mostly ignorant about using the linker beyond using the ide.
extern "C" {
#include "pcre.h"
}
BOOL CPcreTestApp::InitInstance()
{
pcre *re = NULL;
const char* error;
int errorOffset;
char *subject = "Is the string red found in this string?";
int ovector[30];
int subject_length = strlen(subject);
const char* version = pcre_version();
re = pcre_compile("red.+this", 0, &error, &errorOffset, NULL);
int rc = pcre_exec(re, NULL, subject, subject_length, 0, 0, ovector,
30);
.... MFC code
}
The above compiles ok, but results in the following link errors:
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_exec
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_compile
PcreTest.obj : error LNK2001: unresolved external symbol
__imp__pcre_version
The pcre library comes with several .def files, but the various
combinations I've tried don't help.
I've got pcre_vc6d.lib specified in the .dsp file, but it isn't able
to resolve. I've been able to get it to compile/link/run as a
"vanilla" C project with PcreTestConsole.c linking to
Debug\pcre_vc6d.lib, so building the library seems to work.
Do I need something like pcre_mfc.def and, if so, what would it
contain? Is there some parameter to the compiler or linker I need?
Should I build the pcre_vc6d.lib differently?
Here is a link to the vc6 project:
http://www.berbible.org/misc/PcreTest.zip