Hello, I've been trying to use the Visual APR dll on MINGW, and finally managed
to have success. Hoewever it requires a patch in apr.h to work, and I would like
to submmit it to your approval:

Steps to make MSVC apr.dll work on MINGW:

1) Change line 142 in "apr.h" from:
#ifndef __attribute__
#if !defined(__attribute__) && !defined(__MINGW32__)

This is of maximum importance, since we need to assure that the attribute is not
redefined. If we don't do this, function in APR will not be correctly declared
as _declspec(dllimport) ___stdcall, and we will not be able to link. That's why
I suggest this being incorporated into APR, since it doesn't have any side 

2) Generate an exports def from libapr.dll:

  pexports libapr.dll > libapr.def

3) Seperate the stdcall functions from the cdecl funtions in two defs. This is
necessary since we need to build the libraries passing different parameters to
dlltool. Basicaally, we cut&paste the end of the libapr.def in libapr-c.def, and
then add the headers. so libapr-c.def would be

LIBRARY libapr.dll
apr_app_init_complete DATA
apr_day_snames DATA
apr_month_snames DATA
apr_os_level DATA

We will name libapr-s.def the file resulting from cutting the above lines from

4) We create 2 import libs from the above defs:

dlltool -U --input-def libapr-s.def -l libapr-s.a
dlltool --input-def libapr-c.def -l libapr-c.a

Note that the -U option is not passed in the second command. This is because
apr_terminate is declared as a "cdecl" and thus doesn't have an underscore in
the dll.  

5) We can now link our program to libapr-s.a and libapr-c.a, and it shoud work.
However if it is possible to generate a unique lib file for comodity.

6) We are going to merge the two ".a" in to a uniqui lib:

copy libapr-?.a c:"tmp"
cd "tmp
mkdir libapr-s
mkdir libapr-c
mkdir libapr
ar x libapr-s.a
mv *.o libapr-s
ar x libapr-c.a
mv *.o libapr-c

7) Now enter libapr-c and rename all the .o files so that they don't clash with
the files in libapr-s. I suggest the following: rename dh.o and dt.o to dhc.o
and dtc.o. The rename all the ds000??.o files so that they correlate with the
ending ds files from libapr-s: that is ds00001.o from libapr-c.a will become
ds00392.o, ds00002.o --> ds00393.o, etc.

8)Now copy all the resulting .o files from libapr-s and libapr-c to libapr

cd "tmp
copy libapr-c"*.o libapr
copy libapr-s"*.o libapr

You should not need to replace any file. If you are asked, then you have to
rename the file wich wants to be overwritten (step 7).

9) Generate libapr.a

cd "tmp"libapr
ar q libapr.a *.o
ranlib libapr.a

10) That's it! Link your program to libapr.a and it should work.

Reply via email to