I have 3 MSVC projects: static library, dll (linking static lib), exe (linking dll).
- In static lib I define a function
fnStaticLib()
and declare it as exportable symbol. - Dll links in that static library.
fnStaticLib()
is expected to be exported from Dll. - Exe statically links Dll and calls
fnStaticLib()
.
I get error message: 3>exe.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl fnStaticLib(void)" (_imp?fnStaticLib@@YAXXZ)
Seems like linker just throw out that symbol.
The thing is that it works in our production code, with VS projects. There we have quite large static libs linked to dll projects. I just don't which option or whatever makes it work. Now we try to substitute .vcxproj by CMake (via MSBuild). And it doesn't work with CMake-produced .vcxproj files.
Demo project https://github.com/RomanKhv/static_linkage_opt
Thank you in advance!