v1.1.42 / Win32 MinGW problem (and solution) / ac_cv_sys_symbol_underscore
/ GNUPG_SYS_SYMBOL_UNDERSCORE
Ludovic LANGE
llange@users.sourceforge.net
Thu, 28 Aug 2003 13:50:22 +0200
Hello,
When compiling libgcrypt 1.1.42 under a MinGW toolchain (Win32 dev
environmenent, MinGW 3.0.0-rc4, gcc 3.3.1) I do have a problem when
creating a DLL.
When creating the DLL (with the help of the 'build-dll' script, present
in CVS but not in releases, and the following command line instead of
the dlltool process:
gcc -shared -o libgcrypt.dll $OBJS -L/usr/local/lib -lgpg-error
-Wl,--out-implib,libgcrypt.a -Wl,--enable-auto-image-base) I have many
complaints about undefined symbols :
Ex :
../mpi/mpi-add.o(.text+0x3ab): In function `gcry_mpi_add':
mpi/mpi-inline.h:72: undefined reference to `_gcry_mpih_add_n'
../mpi/mpi-bit.o(.text+0x309): In function `gcry_mpi_rshift':
mpi/mpi-bit.c:206: undefined reference to `_gcry_mpih_rshift'
../mpi/mpi-div.o(.text+0x395): In function `gcry_mpi_tdiv_qr':
mpi/mpi-div.c:219: undefined reference to `_gcry_mpih_lshift'
etc...
I traced back these problems to the file : mpi/sysdeps.h which reads :
===========
#define C_SYMBOL_NAME(name) name
===========
instead of (in the 1.1.12 release)
===========
#if __STDC__
#define C_SYMBOL_NAME(name) _##name
#else
#define C_SYMBOL_NAME(name) _/**/name
#endif
===========
This seems to be linked with the removal of the macro definition
GNUPG_SYS_SYMBOL_UNDERSCORE (acinclude.m4, cvs log for rev 1.39 :
http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/libgcrypt/acinclude.m4 ) which
used to define the symbol 'ac_cv_sys_symbol_underscore'.
The (ugly) solution I found was the editing of mpi/config.links from
===========
# Make sysdep.h
echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
if test x$ac_cv_sys_symbol_underscore = xyes; then
cat <<EOF >>./mpi/sysdep.h
#if __STDC__
#define C_SYMBOL_NAME(name) _##name
#else
#define C_SYMBOL_NAME(name) _/**/name
#endif
EOF
else
cat <<EOF >>./mpi/sysdep.h
#define C_SYMBOL_NAME(name) name
EOF
fi
===========
to
===========
# Make sysdep.h
echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
cat <<EOF >>./mpi/sysdep.h
#if __STDC__
#define C_SYMBOL_NAME(name) _##name
#else
#define C_SYMBOL_NAME(name) _/**/name
#endif
EOF
===========
But as I don't understand a thing about this underscore problem, I
cannot tell if it is the right thing to do or not.
However, it helps me compiling libgcrypt as a DLL (Well, I only have 2
undefined symbols now : 'rndw32_gather_random_fast' and 'geteuid' that I
will try to fix.)
Best regards,
Ludovic LANGE