Description of problem:
Linking against the MinGW port of bzip2 fails. For start, code generated by standard configure tests such as
AC_CHECK_LIB(bz2, BZ2_bzopen, ...)
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create the following C code (essentially what configure creates as conftest.c), calling it conftest.c:
char BZ2_bzopen ();
int main ()
return BZ2_bzopen ();
i686-pc-mingw32-gcc -o conftest.exe -g -O2 conftestc.c -lbz2
/home/yeti/tmp/ccEfyAbq.o: In function `main':
/home/yeti/xxx/conftest.c:5: undefined reference to `_BZ2_bzopen'
collect2: ld returned 1 exit status
It links and creates conftest.exe.
According to i686-pc-mingw32-nm, symbols in libbz2.dll.a bear extensions such as @8, @10, etc., so BZ2_bzopen is there as _BZ2_bzopen@8.
Created attachment 577056 [details]
A patch is attached that appears to fix the library for me by removing the WINAPI trickery in the header (apparently intended for native Win32). I do not understand the Win32 stuff enough to say this is the right fix though.
That's not the correct solution. It will make the functions use the cdecl calling convention instead of stdcall upstream uses and thus make the bzip2 DLL we ship binary-incompatible with the upstream one.
Renaming the DLL's symbols to remove the default stdcall mangling (those @8 etc. suffixes) is also binary-incompatible.
I see. So does the configure test (and possibly linking) of every cross-compiled program using bzip2 need to be changed and how? Or are there other options?
This is a general and very serious braindamage in autoconf: compiling test programs without including the necessary header files does not work in general. It might have been expected to work that way 20+ years ago, but today it's just broken.
So, there is no bug in mingw32-bzip2. I may still want a cdecl version of it but that not relevant to this bug report. Thanks for your time.
mingw-bzip2-1.0.6-1.fc17 has been submitted as an update for Fedora 17.
mingw-bzip2-1.0.6-1.fc17, mingw-boost-1.48.0-8.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.