Friday, July 3, 2009

MinGW: Porting GNU Regex to Windows

I am not sure if this regex thing is really necessary. Because it was mentioned in README.xmingw, I'll compile it just in case. I downloaded regex-0.12.tar.gz from http://ftp.gnu.org/old-gnu/regex/ and compiled it as follows:


cd $HOME
tar xzvf regex-0.12.tar.gz
cd regex-0.12/
gcc -DSTDC_HEADERS -DHAVE_STRING_H=1 -I. -c regex.c
ar ru libregex.a regex.o
cp libregex.a /mingw/lib
cp regex.h /mingw/include/


Using the PCRE library instead


The Perl Compatible Regular Expressions (PCRE) library can be used as replacement for the POSIX regex functions. Download the latest pcre library from here and compile it as follows:


./configure --prefix=/mingw --enable-pcre16 --enable-unicode-properties
make
make install

Rename some files so that programs requiring regex can be linked with pcre library.


cd /mingw/include
cp pcreposix.h regex.h

And,
cd /mingw/lib
cp libpcreposix.a libregex.a
cp libpcreposix.dll.a libregex.dll.a

2 comments:

  1. Thanks, however I would recommend dropping the "-g" argument to forgo debugging symbols and putting "-DSTDC_HEADERS" to use the standard C library

    ReplyDelete
    Replies
    1. Hi, Jordan. Thanks for your comment. I updated the post with your advice.

      Delete

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger