Link to home
Start Free TrialLog in
Avatar of tigerman82
tigerman82

asked on

How to compile only pcre_exec.c in Visual C?

Hi,

Is there any way of compiling pcre_exec without getting any error or warning messages?
Avatar of Infinity08
Infinity08
Flag of Belgium image

Probably. But without seeing the code or knowing the error messages you get, I can't really say anything more ...
Avatar of tigerman82
tigerman82

ASKER

Hi,

Attached is the error messages I get
1>------ Build started: Project: test pcre_exec, Configuration: Debug Win32 ------
1>Compiling...
1>pcre_exec.c
1>c:\test pcre_exec\pcre_exec.c(699) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(699) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(726) : warning C4013: 'GET' undefined; assuming extern returning int
1>c:\test pcre_exec\pcre_exec.c(801) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(807) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(813) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(814) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(824) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(830) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(830) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(838) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(838) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(856) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(860) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(860) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(881) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(895) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(947) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(963) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(974) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(983) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1015) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1034) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1041) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1067) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1067) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1076) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1149) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1176) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1186) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1194) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1204) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1229) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1237) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1247) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1290) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1290) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1338) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1351) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(1365) : error C2065: 'LINK_SIZE' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(4473) : error C2065: 'MATCH_LIMIT' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(4474) : error C2065: 'MATCH_LIMIT_RECURSION' : undeclared identifier
1>c:\test pcre_exec\pcre_exec.c(4576) : error C2065: 'NEWLINE' : undeclared identifier
1>Build log was saved at "file://c:\Test pcre_exec\test pcre_exec\Debug\BuildLog.htm"
1>test pcre_exec - 42 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Open in new window

For which code ?

Where is LINK_SIZE declared ? (same for the others)
You are not declared LINK_SIZE corrected
A variable's type should  be specified  before it can be used.
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

this is where the original code is, which is proven to work.  All I am trying to do is to compile only the pcre_exec.c file and to find out which other header files are attached to it.
LINK_SIZE is a macro that needs to be defined to tell PCRE how big its regular expression can be.

As the doc out the header says below, this should be set to 2 by default; however, you can override this using -D on the compilers command line.
/* PCRE keeps offsets in its compiled code as 2-byte quantities by default.
   These are used, for example, to link from the start of a subpattern to its
   alternatives and its end. The use of 2 bytes per offset limits the size of the
   compiled regex to around 64K, which is big enough for almost everybody.
   However, I received a request for an even bigger limit. For this reason, and
   also to make the code easier to maintain, the storing and loading of offsets
   from the byte string is now handled by the macros that are defined here.
  
   The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
   the config.h file, but can be overridden by using -D on the command line. This
   is automated on Unix systems via the "configure" command. */

Open in new window

This is a library - why do you want to compile only part of it ?

If you compile the whole library, you can make use of that one part very easily by just linking to the library, and calling the method you need. Don't go through the trouble of getting one file to compile separately.
BTW: I see you're compiling this in Windows? I'd strongly suggest you download the official PCRE7.9 release and build it using CMake, I know this to build properly out of the box in both VC2005 and VC2008 because I built both only last week.

Maybe CMake will make this simpler for you. It's a make system that will generate make files, including Solutions and Projects for Visual Studio. I found a link that explains how to use it to create a solution for PCRE.

http://vcs.pcre.org/viewvc/code/trunk/NON-UNIX-USE?revision=306&pathrev=359

BUILDING PCRE WITH CMAKE

CMake is an alternative build facility that can be used instead of the
traditional Unix "configure". CMake version 2.4.7 supports Borland makefiles,
MinGW makefiles, MSYS makefiles, NMake makefiles, UNIX makefiles, Visual Studio
6, Visual Studio 7, Visual Studio 8, and Watcom W8. The following instructions
were contributed by a PCRE user.

1. Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
   that cmake\bin is on your path.

2. Unzip (retaining folder structure) the PCRE source tree into a source
   directory such as C:\pcre.

3. Create a new, empty build directory: C:\pcre\build\

4. Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
   for Msys/MinGW or Visual Studio Command Prompt for VC/VC++

5. Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
   directories, respectively

6. Hit the "Configure" button.

7. Select the particular IDE / build tool that you are using (Visual Studio,
   MSYS makefiles, MinGW makefiles, etc.)

8. The GUI will then list several configuration options. This is where you can
   enable UTF-8 support, etc.

9. Hit "Configure" again. The adjacent "OK" button should now be active.

10. Hit "OK".

11. The build directory should now contain a usable build system, be it a
    solution file for Visual Studio, makefiles for MinGW, etc.

you can create a new visual studio project by adding all .c , .h files ,and from that visual studio project file prce_exec.c you can find what are all files linked .
>> you can create a new visual studio project by adding all .c , .h files
It's really not necessary to do this since the standard solution, generated using cmake, separates everything into discrete projects so you can control what you need to build using the solution configuration manager.
Is there anyway I can do this straight in Visual Studio without having to use CMake?  I am trying to find how pcre_exec is linked to other files so that I can extract this processing engine for me to do further analysis.
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is CMake going to change the original codes in any way because that would actually defeat the purpose.
>> Is CMake going to change the original codes in any way because that would actually defeat the purpose.
Not to the best of my knowledge... it just generate solutions and projects. To be 100% sure take a copy of your original, generate using cmake and then use something like WinMerge to diff (WinMerge will diff whole directory trees).
you can create a new project with out using cmake and add all files and find the links
>> you can create a new project with out using cmake and add all files and find the links
But there are many config settings that won't be set will need to be figured out (which is what the original problem is all about!). By generating the CMake project (which is the correct and official way to do this) you'll have a template to work from, which will include all the settings you need to know about. Why guess where it's already been done for you?