完美编译运行PCRE on Windows , Solved the __imp__pcre_exec __imp__pcre_compile __imp__pcre_free Errors
来源:互联网 发布:龙之信条saber捏脸数据 编辑:程序博客网 时间:2024/06/05 01:07
写写英文吧,好长时间不写都有点不熟练了when I compile the following codes which test the pcre , I got the unreferenced error __imp__pcre_exec __imp__pcre_compile __imp__pcre_free Errors,my Codes are follows:
//packing pcre usual functions.#ifndef _PCRE_H_#define _PCRE_H_#include <pcre.h>#include <string>#include <vector>#include <string.h>using namespace std;const int VECSIZE = 30;struct MatchResult{string name;vector<string> value;};class Pcre{public:Pcre();~Pcre();//Add a regrex, pass in name and regrexint AddRule(const string &name, const string &patten);//clear all the regrexvoid ClearRules();//match all the regrex, also return all the string match to every regrexvector<MatchResult> MatchAllRule(const char content[]);private:const char *error;int erroffset;int ovector[VECSIZE];vector<pcre*> re_arr;vector<string> patten_name;};#endif
Pcre.cpp
#include "Pcre.h"#include <stdio.h>Pcre::Pcre(){re_arr.clear();patten_name.clear();}Pcre::~Pcre(){for(int i=0; i<re_arr.size(); i++) { pcre_free(re_arr[i]); }}//Add a regrex patten and compile it.int Pcre::AddRule(const string &name, const string &patten){pcre *re = pcre_compile(patten.c_str(), PCRE_MULTILINE|PCRE_UTF8|PCRE_NO_AUTO_CAPTURE, &error, &erroffset, NULL); if(re == NULL) { printf("pcre compile failed, offset %d: %s\n", erroffset, error);return -1; }else{re_arr.push_back(re);patten_name.push_back(name);}}//clear all the rulevoid Pcre::ClearRules(){for(int i=0; i<re_arr.size(); i++){pcre_free(re_arr[i]); }re_arr.clear();patten_name.clear();}//match all regrex, if any match, return the matched patten name and it's valuesvector<MatchResult> Pcre::MatchAllRule(const char content[]){vector<MatchResult> result_arr;int length = strlen(content);char buf[512];for(int i=0; i<re_arr.size(); i++){MatchResult result;result.name = patten_name[i];int cur = 0;int rc; while(cur<length && (rc = pcre_exec(re_arr[i], NULL, content, length, cur, PCRE_NOTEMPTY, ovector, VECSIZE)) >= 0) { for(int j=0; j<rc; j++) {memset(buf, 0, sizeof(buf));strncpy(buf, content+ovector[2*j], ovector[2*j+1]-ovector[2*j]); result.value.push_back(buf); } cur = ovector[1];}if(result.value.size() > 0)result_arr.push_back(result);}return result_arr;}
Main.cpp
1>正在生成代码...1>正在链接...1>Pcre.obj : error LNK2001: 无法解析的外部符号 __imp__pcre_free1>Pcre.obj : error LNK2001: 无法解析的外部符号 __imp__pcre_compile1>Pcre.obj : error LNK2001: 无法解析的外部符号 __imp__pcre_exec1>.\Debug/main.exe : fatal error LNK1120: 3 个无法解析的外部命令1>生成日志保存在“file://E:\Test\Pcre-Test\Debug\BuildLog.htm”1>main - 4 个错误,7 个警告========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
Google it , I found the thread about the error, a comment gives the solutions:
Building under Windows:
If you want to statically link this program against a non-dll .a file, you must
define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc() and
pcre_free() exported functions will be declared __declspec(dllimport), with
unwanted results. So in this environment, uncomment the following line. */
//#define PCRE_STATIC
try it ... successful !!!!
- 完美编译运行PCRE on Windows , Solved the __imp__pcre_exec __imp__pcre_compile __imp__pcre_free Errors
- Windows下编译pcre
- windows平台编译pcre
- windows平台手动编译pcre
- pcre++ windows版本编译过程
- PCRE在windows+VS2013编译
- Windows下VS2010编译PCRE
- eclipse运行时报errors occurred during the build. errors running builder "android package builder" on pro
- Linux和windows下编译pcre
- 在WINDOWS下编译PCRE库
- windows平台cl.exe编译pcre 8.13
- windows平台使用CMake编译pcre库
- Windows上面编译pcre的步骤
- Determining the source of Bug Check 0x133 (DPC_WATCHDOG_VIOLATION) errors on Windows Server 2012
- PCRE++编译
- 正则库相关及windows-VS-C++环境下pcre && pcre++的编译和使用
- 最新pcre库在windows平台编译完整过程
- 如何在Windows下通过Cmake编译和使用PCRE
- 如何拿53kf的会员信息
- Android 触摸屏手势识别程序
- Visual Stdio 的的常用快捷键
- 谷歌实习生,只要大二的妹子
- Android Intent 用法全面总结
- 完美编译运行PCRE on Windows , Solved the __imp__pcre_exec __imp__pcre_compile __imp__pcre_free Errors
- 腾讯2012实习生笔试题2+答案解析
- 交换机与路由器的区别
- 子窗口和父窗口的消息传递
- 数据库left join
- XMPP功能列表
- 黑马程序员 java_网络编程笔记
- 网络通,但打不开网页——(本文来自黑客基地)
- win7下安装VC6LineNumberAddin方法[VC6行号插件]及问题解决方案