dll - Import library creation, C++/VisualStudio2013 -


i create set of c++ dlls , import libraries in visualstudio (2013). far, these generated @ same time linker. dlls use symbols other libraries, included additional dependencies in properties/link edition.

sometimes, dll generation fails because of missing importation libraries, fine me, in such case there's no generated .lib file either. generate import libs (of dlls) if dlls cannot done, in order allow other projects rely on symbols shall export before i'm able provide whole stuff.

i found workaround through pre-link event command line, with:

  • lib /def:(...)\mylib.def /out:(...)\mylib.lib $(intdir)*.obj

this generates need, when have .def file.

the problem is, don't have such .def file rely on __declspec(dllexport) instructions instead, , in such case didn't find way correct result.

i tried:

  • lib /out:(...)\mylib.lib $(intdir)*.obj (#1)
    creates (static ?) lib file, not import library, not need.

  • lib /def /out:(...)\mylib.lib $(intdir)*.obj (#2)
    fails on error 1104 because of missing (other) import libraries.

what's more puzzling me is, command line (#2) fails on libraries should here (they found linker, actually). i'm wondering whether supposed provide complete link command line arguments lib command, in case no-go.

i'm not of specialist of compilation/link tools, fear, i'm doing pretty wrong stuff...

does know of simple way fulfill need without using .def file ? there option in linker ask import library creation declared __declspec(dllexport) symbols , generate when dll cannot link ?

this fails on error 1104 because of missing (other) import libraries.

edit: oh, it. .obj files have /defaultlib: inside them , lib complains. use /nodefaultlib

hasunresolved.c:

#pragma comment(lib, "missinglib.lib")  void missingfunc();  __declspec(dllexport) void dllfunc() {     missingfunc(); } 

usedll.c

__declspec(dllimport) void dllfunc();  int main() {     dllfunc();     return 0; } 

in vs command prompt:

cl -c hasunresolved.c  lib /def /out:test.lib hasunresolved.obj rem prints: lib : fatal error lnk1104: cannot open file 'missinglib.lib'  lib /nodefaultlib /def /out:test.lib hasunresolved.obj  cl usedll.c test.lib dumpbin /imports:test.dll usedll.exe 

output:

dump of file usedll.exe     test.dll                     0 dllfunc 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -