[Mingw-users] How to generate the _imp_ prefix?

Eli Zaretskii eliz****@gnu*****
Wed Jan 22 03:02:30 JST 2020

[Please keep the discussion on the list.]

> From: Joachim Wuttke <j.wut****@fz-ju*****>
> Date: Tue, 21 Jan 2020 18:09:37 +0100
> > Isn't the __imp__ prefix supposed to be in the import library, not in
> > the shared library (a.k.a. "DLL")?  And if mylib.lib _is_ an import
> > library, then how did you build it, exactly, i.e. with what MinGW
> > commands?
> Yes, mylib.lib is supposed to be an import library. This is where
> VS searches for symbols at link time. Until linking succeeds,
> I am not concerned about the DLL.
> The mylib project has tests that are linked with mylib.lib, and
> executed using mylib.dll. Works under MinGW. So the problem is
> with cross-compilation.
> Compilation is under control of gitlab-runner and CMake. The
> decisive line in .gitlab-ci.yml is
>      - cmake -G "Ninja" -DLIB_MAN=OFF -DCMAKE_INSTALL_PREFIX=C:\opt\x64 -B. -DCMAKE_GNUtoMS=ON ..

Ouch, Cmake!  Who knows what it does under the hood?  Did you
configure it correctly for MinGW, at least?  Perhaps ask it to display
all the commands verbosely and see what it actually does?

Anyway, the way I usually produce import libraries is via the
"-Wl,--out-implib=" switch to GCC on the link command line.  That
produces import libraries with the __imp__ prefixes, so this stuff
does work and the produced libraries should be usable with MSVC
(although I never tried).

More information about the MinGW-Users mailing list