c - Is it possible to link against a Windows .dll+.lib file combination using gcc/g++ under Cygwin? -
i know how link against libraries in unix-ish contexts: if i'm working .a
or .so
files, specify root search directory -l/my/path/to/lib/
, libmylib add -lmylib
.
but if have
- a
.dll
(e.g. inwindows\system32
directory)? - a
.dll
(inwindows\system32
) ,.lib
(someplace else)?
these dlls other party; don't have access sources - have access corresponding include files, against manage compile.
if can link against .lib
in cygwin or mingw, can (indirectly) link against dll.
in msvc world, not unusual create import library along dll. static library (.lib
) loads dll , wraps interface of dll. call wrapper functions in (static) import library , let import library dll-related things.
- for windows api, there import libraries in windowssdk.
- for own msvc dlls, msvc can automatically generate import libraries when build dll.
- for third party dll, can build static wrapper library based on corresponding header files.
linking against .lib
file in cygwin or mingw possible. example:
g++ -o myprg myprg.o -lshlwapi
this links against shlwapi.lib. (the library must in local directory or in library path of linker.)
linking against import libraries of dlls works same way.
note 1: keep in mind different abis , name mangeling. however, calling plain c functions in dll or lib files work in cases.
note 2: keep in mind g++ requires libraries specified in correct order.
Comments
Post a Comment