(0)从http://gnuwin32.sourceforge.net/packages/pcre.htm  (pcre windows)下下载最新的windows平台源代码pcre-7.0-src.zip,不要选择开发包以及bin文件,由于编译器(bcc以及交叉编译器)的差异,会导致这些不同后缀名得库用不了,浪费时间。

(1) Copy or rename the file config.h.in asconfig.h, and change the macros that

define HAVE_STRERROR and HAVE_MEMMOVE to definethem as 1 rather than 0.

Unfortunately, because of the way Unix autoconfworks, the default setting has

to be 0. You may also want to make changes toother macros in config.h. In

particular, if you want to force a specific valuefor newline, you can define

the NEWLINE macro. The default is to use '\n',thereby using whatever value

your compiler gives to '\n'.

rem MarkTetrode's commands

copyconfig.h.in config.h

rem Usewrite, because notepad cannot handle UNIX files. Change values.

writeconfig.h

将config.h.in文件中的 #define HAVE_STRERROR 0和#defineHAVE_MEMMOVE 0改成 #define HAVE_STRERROR 1和#define HAVE_MEMMOVE 1后复制为config.h

(2) Compile dftables.c as a stand-alone program,and then run it with

the single argument "pcre_chartables.c".This generates a set of standard

character tables and writes them to that file.

rem MarkTetrode's commands

remCompile & run

cl-DSUPPORT_UTF8 -DSUPPORT_UCP dftables.c

dftables.exe pcre_chartables.c

直接在src目录下,用vc6.0代开dftables.c,编译生成一个项目,然后在 工程-》设置-》C/C++-》常规-》预处理程序定义中,加入“,SUPPORT_UTF8,DSUPPORT_UCP”,编译成功,然后用cmd来执行dftables.exepcre_chartables.c。

(3) Compile the following source files:

pcre_chartables.c

pcre_compile.c

pcre_config.c

pcre_dfa_exec.c

pcre_exec.c

pcre_fullinfo.c

pcre_get.c

pcre_globals.c

pcre_info.c

pcre_maketables.c

pcre_newline.c

pcre_ord2utf8.c

pcre_refcount.c

pcre_study.c

pcre_tables.c

pcre_try_flipped.c

pcre_ucp_searchfuncs.c

pcre_valid_utf8.c

pcre_version.c

pcre_xclass.c

and link them all together into an object libraryin whichever form your system

keeps such libraries. This is the pcre C library.If your system has static and

shared libraries, you may have to do this once foreach type.

rem Thesecomments are out-of-date, referring to a previous release which

rem hadfewer source files. Replace with the file names from above.

rem MarkTetrode's commands, for a static library

remCompile & lib

cl-DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 -DPCRE_STATIC  /c maketables.c get.c study.c pcre.c

lib/OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj

搜索所有的c文件,从src中拷出来,放在单独的文件夹下,并删除不需要的c文件。

所有所有的h文件,从src中拷出来,放在同一个单独的文件夹下。

新建一个空白静态链接库工程,添加所有文件到工程中,然后在  工程-》设置-》C/C++-》常规-》预处理程序定义 中,加入“,SUPPORT_UTF8,DSUPPORT_UCP,POSIX_MALLOC_THRESHOLD=10,PCRE_STATIC”,其中PCRE_STATIC是必须的,否则后面exe link 库会出现undefined sympol_smp_等找不到函数的问题。

在编译连接的时候,需要添加另外一个ucptable.c和pcre_printint.src,然后编译成功。

(4) Similarly, compile pcreposix.c and link it (onits own) as the pcreposix

library.

rem MarkTetrode's commands, for a static library

remCompile & lib

cl-DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 -DPCRE_STATIC  /c pcreposix.c

lib/OUT:pcreposix.lib pcreposix.obj

将pcreposix.c拷贝到单独的文件夹下,将所有h文件拷贝在同一个文件夹下,创建空白静态库工程,设置同样的预定义指令,然后编译成功。

(5) Compile the test program pcretest.c. Thisneeds the functions in the

pcre and pcreposix libraries when linking.

rem MarkTetrode's commands

remcompile & link

cl -MD/F0x400000 pcretest.c pcre.lib pcreposix.lib

将pcretest.c 和所有的h文件拷贝到单独文件夹下,然后创建空白console应用,然后 工具-》选项-》目录-》库路径,设置pcre.lib和posixpcre.lib的路径,然后在 工程-》设置-》对象/库模块 中 加入pcre.lib pcreposix.lib,最后关键的是工程-》设置-》代码生成-》使用运行时库-》多线程DLL,也就是将工程选项中添加/MD ,最后编译成功。

(6)随意在网上找个例子,同样注意要设置/MD,均可编译运行成功。

High Points

(1)useful url(pcre静态库):根据src下的NON-UNIX-USE将两个库勉强编译出来,根据此贴才终于将连接库函数失败(nresolved external symbol_pcre_free)得到提醒,才终于连接成功。

http://topic.csdn.net/u/20110504/15/3e7bb67a-79de-4eb3-9aba-60136dc6ce12.html

(2)compile two libraries -DPCRE_STATIC

(3)compile exe -MD

(4)一个使用实例(PCRE函数简介和使用示例)

http://blog.csdn.net/sulliy/article/details/6247155

  1. #define PCRE_STATIC // 静态库编译选项
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "pcre.h"
  5. #define OVECCOUNT 30 /* should be a multiple of 3 */
  6. #define EBUFLEN 128
  7. #define BUFLEN 1024
  8. int main()
  9. {
  10. pcre  *re;
  11. const char *error;
  12. int  erroffset;
  13. int  ovector[OVECCOUNT];
  14. int  rc, i;
  15. char  src [] = "111 <title>Hello World</title> 222";   // 要被用来匹配的字符串
  16. char  pattern [] = "<title>(.*)</(tit)le>";              // 将要被编译的字符串形式的正则表达式
  17. printf("String : %s/n", src);
  18. printf("Pattern: \"%s\"/n", pattern);
  19. re = pcre_compile(pattern,       // pattern, 输入参数,将要被编译的字符串形式的正则表达式
  20. 0,            // options, 输入参数,用来指定编译时的一些选项
  21. &error,       // errptr, 输出参数,用来输出错误信息
  22. &erroffset,   // erroffset, 输出参数,pattern中出错位置的偏移量
  23. NULL);        // tableptr, 输入参数,用来指定字符表,一般情况用NULL
  24. // 返回值:被编译好的正则表达式的pcre内部表示结构
  25. if (re == NULL) {                 //如果编译失败,返回错误信息
  26. printf("PCRE compilation failed at offset %d: %s/n", erroffset, error);
  27. return 1;
  28. }
  29. rc = pcre_exec(re,            // code, 输入参数,用pcre_compile编译好的正则表达结构的指针
  30. NULL,          // extra, 输入参数,用来向pcre_exec传一些额外的数据信息的结构的指针
  31. src,           // subject, 输入参数,要被用来匹配的字符串
  32. strlen(src),  // length, 输入参数, 要被用来匹配的字符串的指针
  33. 0,             // startoffset, 输入参数,用来指定subject从什么位置开始被匹配的偏移量
  34. 0,             // options, 输入参数, 用来指定匹配过程中的一些选项
  35. ovector,       // ovector, 输出参数,用来返回匹配位置偏移量的数组
  36. OVECCOUNT);    // ovecsize, 输入参数, 用来返回匹配位置偏移量的数组的最大大小
  37. // 返回值:匹配成功返回非负数,没有匹配返回负数
  38. if (rc < 0) {                     //如果没有匹配,返回错误信息
  39. if (rc == PCRE_ERROR_NOMATCH) printf("Sorry, no match .../n");
  40. else printf("Matching error %d/n", rc);
  41. pcre_free(re);
  42. return 1;
  43. }
  44. printf("/nOK, has matched .../n/n");   //没有出错,已经匹配
  45. for (i = 0; i < rc; i++) {             //分别取出捕获分组 $0整个正则公式 $1第一个()
  46. char *substring_start = src + ovector[2*i];
  47. int substring_length = ovector[2*i+1] - ovector[2*i];
  48. printf("$%2d: %.*s/n", i, substring_length, substring_start);
  49. }
  50. pcre_free(re);                     // 编译正则表达式re 释放内存
  51. return 0;
  52. }

pcre7.0在vc6.0编译的更多相关文章

  1. VC6.0常见编译错误提示

    原文:http://c.biancheng.net/cpp/html/746.html 1) error C2001: newline in constant 编号:C2001 直译:在常量中出现了换 ...

  2. VC6.0编译boost

    今天学习了下VC6.0下boost的编译,只是对regex进行了编译,据说全部编译需要2个多小时,在此记录下学习过程中遇到的问题以便今后查看. 最开始直接从网上(www.boost.org)下载了当前 ...

  3. vc6.0批量编译

    一直想研究一下怎么让电脑批处理编译程序,今天就从vc6开始,做个记录,学习一下. VC可以生成make文件(Project->Export Makefile),在设置好环境变量下,执行NMAKE ...

  4. 比特币初始版本VC6.0编译

    1 源码下载 github上初始版本是bitcoin-0.1.5,可以从https://github.com/bitcoin/bitcoin下载,但是从网上可以找到更老版本bitcoin-0.1.0, ...

  5. VC6.0编译DLL,使用VS2010调用问题及解决方法

    1.做驱动的时候.做应用程序须要和驱动通信,必须建立一个DLL. 2.由于客户使用版本号太低,须要使用到VC6.0编写DLL 3.在VC6.0上编写DLL的时候,导出的函数名会出现和原函数名不正确,导 ...

  6. 让VC6.0编译出来的程序支持XP样式或XP风格

    (1)VC6.0编译出来的win32程序不支持winxp样式的原因:微软WINXP系统更新了Comctl32.dll(ver 6.0)这个“XP风格”的控件.为了保留传统的Windows界面风格,特地 ...

  7. Berkeley DB (VC6.0 编译环境配置)

    操作系统:winxp VC环境:VC6.0 必需文件:Berkeley DB安装文件(db-.msi) 下载地址:http://www.oracle.com/technology/software/p ...

  8. vc6.0 点编译时提示Cannot complile the file &#39;D:\souce-code\vc-workspace\对话框\MainFrm.h&#39;; no compile tool is

    问题描写叙述: vc6.0程序,点击编译时提示对话框,内容为: Cannot complile the file 'D:\souce-code\vc-workspace\对话框\MainFrm.h'; ...

  9. 使用VC6.0编译C++代码的时候报错:fatal error C1071: unexpected end of file found in comment(Mark ZZ)

    fatal error C1071: unexpected end of file found in comment(Mark ZZ) 今天在一论坛上看到一人发帖: 『最近遇到一个奇怪的问题,代码中的 ...

随机推荐

  1. 洛谷 P1548 棋盘问题

    题目描述 设有一个N*M方格的棋盘(l<=N<=100,1<=M<=100)(30%) 求出该棋盘中包含有多少个正方形.多少个长方形(不包括正方形). 例如:当 N=2, M= ...

  2. dos命令及HTML基础语法

  3. 网新恩普(T 面试)

    1.你们项目中哪里用到了Redis? 2.介绍一下你的这个微服务项目

  4. es6 fs 输出文件 iviewDemo

    // fs.open('./env.js', 'w', function(err, fd) { // // const buf = 'export default "development& ...

  5. 已安全化的ActiveX控件卸载时出现"DllUnregisterServer函数出错,错误代码:0x80070002"问题解决

    已安全化的ActiveX控件卸载时出现"DllUnregisterServer函数出错,错误代码:0x80070002"问题解决   情况一:当该控件未注册或者已经卸载时,你尝试卸 ...

  6. executeFind(XXX) is undefined for the type hibernateTemplate(大概是这个错误吧)

    两句话,jar包版本不一样,类中包含的方法可能有改变. 出错时用的是spring5.x版本,但是没有找到我的api.(不记得放在那里了),所以换了spring的版本(换成了spring3.x).问题解 ...

  7. PHP17 PDO

    学习要点 PDO简要 PDO对象 PDO对象的使用 PDOStatement对象 PDO事务处理 PDO简要 PHP支持那些数据库操作 MySQL,Oracle,SQLServer,SQLite.Po ...

  8. P2964 [USACO09NOV]硬币的游戏A Coin Game (DP)

    题意:n颗硬币 两个人从前往后按顺序拿 如果上一个人拿了i颗 那么下一个可以拿1-2*i颗 问先手能获得的最大收益 题解:比较典型的最大最小最大最小..DP了 但是暴力做的话是n^3 所以就体现出了这 ...

  9. docker nginx 负载均衡

    index1.html <html> <head> <title>lb-test</title> </head> <body> ...

  10. luogu 1113 杂务--啥?最长路?抱歉,我不会

    P1113 杂务 题目描述 John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它.比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作.尽早将所有杂务 ...