How to apply Regex in C++?

This is a discussion on How to apply Regex in C++? within the C++ Programming forums, part of the General Programming Boards category; You need to create the boost regex libraries from source. I tried just this morning to create them for VS12 ...

  1. #16
    Registered User
    Join Date
    Mar 2013
    Posts
    33
    You need to create the boost regex libraries from source.
    I tried just this morning to create them for VS12 (aka Visual Studio 2013). FAILED
    boost 1.54 does not recognize the 2013 compiler. I understand there are patches but .....
    I tried with the boost 1.55 beta and while it built the regex library it appears it used /MD and I use /MT for everything.


    If you are using VS12 the C++11 regex is available.


    I did manage to create 32 bit pcre static libraries for use with VS12 a few days ago but it was no picnic.
    They are attached but note they are built with /MT
    I do not use the VS12 ide so it's up to you to find out how to incorporate the libraries.


    James
    Attached Files Attached Files

  2. #17
    Registered User
    Join Date
    Aug 2013
    Posts
    30
    Hello James,

    Thanks for the help. I'm not able yet to make working the pcre with VS. I'll continue trying.

    But how do you create the pcre library?
    What is the difference between this VS12pcre and the other pcre of MinGW distro?

    Thanks again

  3. #18
    Registered User
    Join Date
    Mar 2013
    Posts
    33
    I am still a c++ novice but I'll pass along what I know (may not be correct


    Form the sounds of your posts the creation of the static pcre3 library for VS12 may be a little too advanced for you.
    Because the pcre3 library was created for the nix OS's you have to jump through hoops to make a windows version (or I did any way )
    It is describe in the pcre3 source download.


    All static libraries have to be compiled by the same compiler that will use them. Even different versions of the same compiler.


    James

  4. #19
    Registered User
    Join Date
    Nov 2012
    Posts
    980
    For a C library like PCRE the requirement of using the same compiler can be relaxed, see also here:

    From MinGW static library (.a) to Visual Studio static library (.lib) - Stack Overflow

    Or you can try to find a precompiled PCRE library for visual studio. In any case you will want to use the pcrecpp.h header to give you the C++ wrapper. The header file also includes very good documentation of how to use it. This is my solution for regex in c++. The C++11 regex never seemed to work in the compilers I tried. Besides PCRE is free and pretty much a defacto standard.

  5. #20
    Registered User
    Join Date
    Aug 2013
    Posts
    30
    Hello c99tutorial,

    Thanks for link shared and suggestion. I'll try to search a pcre for visual studio.

    Regards

  6. #21
    Registered User
    Join Date
    Mar 2013
    Posts
    33
    c99tutorial,
    I believe(?) that link is for the static link libraries .a to the dll. The files I supplied are actual VS12 c++ static libraries (no dll). You cannot use object modules compiled with MinGw g++ with an application created with VS12 c++ as far as I know. All he needs is to supply the path to the libraries/includes in Visual Studio. I am not versed in Visual Studio operation. I just use the c++ compiler.

    James

  7. #22
    Registered User
    Join Date
    Nov 2012
    Posts
    980
    Quote Originally Posted by jcfuller View Post
    You cannot use object modules compiled with MinGw g++ with an application created with VS12 c++ as far as I know.
    The PCRE library does not export any c++ (i.e. mangled) symbols, it is purely a C API, which means it will probably work. The link I found is covering that case. Really I would say the best option is to compile it on your own compiler but it could be useful if you can't manage to compile it yourself on Visual Studio.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. regex in c (posix regex)
    By baxy in forum C Programming
    Replies: 1
    Last Post: 11-16-2012, 12:15 PM
  2. Program to apply windows registry settings
    By john3j in forum C Programming
    Replies: 5
    Last Post: 09-21-2012, 08:08 PM
  3. Apply style to multiple windows
    By gaurav_13191 in forum Windows Programming
    Replies: 5
    Last Post: 07-07-2011, 11:59 PM
  4. How to apply selection sort in a two-dimensional array
    By yigster in forum C++ Programming
    Replies: 16
    Last Post: 04-28-2010, 11:56 AM
  5. <regex.h> regex syntax in C
    By battersausage in forum C Programming
    Replies: 7
    Last Post: 03-24-2004, 12:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21