I’m trying to build a simple shared library example.
With the included project, I’ve got an error on build:
"C:\Program Files\CMake\bin\cmake.exe" -E __create_def CMakeFiles\TestShared.dir\exports.def CMakeFiles\TestShared.dir\exports.def.objs
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : code '0xc0000005'
The equivalent project for mingw/gcc compiles and can be used by an application.
How do I fix my CMakeLists?
Thanks in advance, regards,
CMakeExample.7z (2.2 KB)
First of all, a /LD was missing but now I’ve got another issue.
The shared library is compiled and seemed to be properly install but the client application cannot link:
TestExe.cpp.obj : error LNK2001: unresolved external symbol "int __cdecl TestSharedFcn(void)"
I’m joining a more complete example.
CMakeExample.7z (2.4 KB)
PS I suspect that there is an issue with the linkage to the associated import library.
Strangely enough: if I build a second time the error disappears.
I’m still failing to understand why.
Help would be appreciated on the proper way to build a msvc shared library
The issues seems to be related to https://gitlab.kitware.com/cmake/cmake/-/issues/16282
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS usage and using GenerateExportHeader solves the issue in my case.