Bug #49934 Unusable import library due NULL_THUNK_DATA symbol, MinGW and cross compiling
Submitted: 24 Dec 2009 23:56 Modified: 9 Feb 2010 10:06
Reporter: Luis Lavena Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Windows Severity:S2 (Serious)
Version:5.0.89, 5.1.41, 5.0.90, 5.1.43 OS:Linux (Ubuntu 9.10 - mingw32 from apt)
Assigned to: CPU Architecture:Any
Tags: dll, gcc, mingw32, windows

[24 Dec 2009 23:56] Luis Lavena

I maintain and develop a series of shared libraries that are cross-platform.

Because of this cross-platform nature, I decide that will be best generate all the binaries from Linux, since I can easily cross-compile using GCC+MinGW tools.

In Ubuntu, install it is easy as "apt-get install mingw32"

Everything was OK with 5.0.83, but latest versions of mysql (both 5.0 and 5.1) exposed a issue when generating the shared library:

i586-mingw32msvc-gcc -shared -s -o mysql_api.so mysql.o -L. -L/home/luis/.rake-compiler/ruby/ruby-1.8.6-p383/lib -L/home/luis/src/mysql-gem/vendor/mysql-5.1.41-win32/lib/opt -L.   -Wl,--enable-auto-image-base,--enable-auto-import,--export-all   -lmsvcrt-ruby18 -llibmysql  -lshell32 -lwsock32
Cannot exportLIBMYSQL_NULL_THUNK_DATA: symbol not found
collect2: ld returned 1 exit status

As you can see, is complaining about a missing symbol: LIBMYSQL_NULL_THUNK_DATA

After further investigation, found that the symbol start with ASCII 127 (DEL) and cannot be added to -Wl,--exclude-symbols linker option.

Due the lack of reimp under this environment, I cannot reprocess programatically 
 libmysql.lib, and thus, cannot compile.

When tried to use dlltool to collect all the exported symbols (def) and generate a new import library, ended with no symbols being exported by the DLL.

Also, tried to use include/libmysql.def, but is not a valid definition file since the generated import library ends broken.

This turned to be a problem that cannot be resolved very easily and would thank something is done to avoid the above mentioned symbol being exported.

Thank you in advance and looking forward assistance on this issue.

How to repeat:
Under Linux, with Ruby (1.8.6 or 1.9.1)
GCC installed
MinGW32 toolchain installed

clone of this repository:

gem installation: rake, hoe, rake-compiler

change tasks/native.rake MYSQL_VERSION to either 5.0.89 or 5.1.41

Execute "rake cross compile"
[8 Feb 2010 15:32] Sveta Smirnova
Thank you for the report.

Verified as described even with 5.0.83. This can be only considered as feature request though.
[9 Feb 2010 10:06] Luis Lavena
Thank you for reviewing and confirming this.

I would like to escalate this, even is a feature request, since is a blocker for developers working and building Ruby extensions for Windows environment that depends on MySQL.

Without this feature, the exported link libraries turn useless for these users, which will be really helpful to avoid dependency on a real Windows machine to perform these builds.

Thank you in advance for anything that can be done to solve this issue.