Re: PCRE & MFC: problem with link error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Lynn Allan" <l_d_allan@xxxxxxxxxxxx> wrote in message
news:uMaeEhMPIHA.3940@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for your patient help as I wrestle with the linker/librarian

I got the linker to resolve the references with a pcre.def file that has
this contents:
LIBRARY pcre
EXPORTS
pcre_malloc
pcre_free
pcre_config
pcre_callout
pcre_compile
pcre_compile2
pcre_copy_substring
pcre_dfa_exec
pcre_exec
pcre_get_substring
pcre_get_stringnumber
pcre_get_substring_list
pcre_free_substring
pcre_free_substring_list
pcre_info
pcre_fullinfo
pcre_maketables
pcre_study
pcre_version

However, when I try to run the PcreTest.exe, I get an error message about
"missing pcre.dll".

My preference is to statically link the PcreTest.exe and not have to
distribute the pcre.dll.

In the settings for building pcre.lib, I specified:
Configuration Type: Static Library (.lib).
There are also preprocessor #define's for PCRE_STATIC

However, the generated Release\pcre.lib and Release\PcreTest.exe are much
smaller than expected, which would be the case if a .dll was required.

I looked though the build configuration settings for PcreTest.exe and
didn't see anywhere that pcre.dll was required. Is the above pcre.def
incorrect?

Here is a link to the vc6 project with source files. It has an Mfc project
and two console projects:
http://www.berbible.org/misc/pcre-74_071212b.zip


I have successfully built your source code so that the PcreText.exe uses the
static library. I had to change a few things:

1. PcreTest.dsw - Open the PcreTest.dsw in VC6. In FileView, select
"PcreTest files", then activate the Project |Dependencies menu item, and
make pcrelib a dependency. Not only will this cause the PcreTest.exe to be
rebuilt when anything in the library becomes out of date, it will also make
PcreTest link with the built Pcrelib.lib automatically.

2. PcreTest.dsp and PcreLib.dsp - in compiler defines, add PCRE_STATIC.
This is required so that both the library and the exe see prototypes of the
library functions as non-exported so link errors don't occur.

3. PcreTest.cpp - remove the line:
#pragma comment( lib,
"X:\\LdaFwApps\\BerBible\\Prototypes\\RegEx\\PcreVcProject\\Debug\\pcre.lib"
)

because the pcrelib.lib (and not any file called pcre.lib) will be
automatically linked due to change #1 above.


Please try this and I hope it gets you on your way. :-)


-- David


.



Relevant Pages

  • Re: LNK4006 in .NET 2003
    ... I've got all source files ... Dependencies are intended to make header files available in only one ... Compilation of BasicLibrary.lib: OK ... instead of just referencing that lib. ...
    (microsoft.public.vc.language)
  • Reducing build-times for large projects.
    ... I have read item 26 of "Exceptional C++" that explains a way of minimising ... compile-time dependencies and, therefore, a way to improve compile speeds. ... a potentially large number of source files may have previously ...
    (comp.lang.cpp)
  • Re: dependency-detection in java - Take 2
    ... dependencies to make an incremental build as reliably ... "correct" as a full rebuild. ... from source files that have been deleted. ... then remove the .class file. ...
    (comp.lang.java.programmer)
  • makefile
    ... compiling Fortran90 programs. ... It can automatically detect the dependencies between source files as ... long as some conventions are followed. ...
    (comp.lang.fortran)