Closed jakoch closed 3 years ago
Looks like you have a static build but the header file thinks you use the shared library.
You can fix that by defining STATIC
in your compiler flags.
The issue is not resolved for me.
The dependencies are build with -DBUILD_SHARED_LIBS=OFF
(from vcpkg's triplet x64-windows-static
).
My other dependencies are sqlite3
and curl
. Both are statically linked and their symbols are found.
The application is build with -DBUILD_SHARED_LIBS=OFF
.
Would you be so nice to elaborate on how to that (define STATIC
)?
I'm not an MSVC expert, but I believe you just need to add /D STATIC
to the compiler flags.
When using cmake I suppose you can do that with -DCMAKE_C_FLAGS:STRING="/D STATIC"
and/or -DCMAKE_CXX_FLAGS:STRING="/D STATIC"
.
Ok, that works. Thank you.
Yes, one needs to define STATIC
or BUILD_XLSXIO_STATIC
.
Referencing: https://github.com/brechtsanders/xlsxio/blob/master/include/xlsxio_read.h#L65
I'm including now like this:
#define BUILD_XLSXIO_STATIC
#include "xlsxio_read.h"
Thats the ugly way to do it. If you want your source to be able to build to both static and shared you should really define STATIC
somewhere in the build system, not in the code.
Agreed, it's kind of ugly.
Maybe it's better to set this from my CMakeLists.txt
:
if(BUILD_SHARED_LIBS)
target_compile_definitions(app PRIVATE BUILD_XLSXIO_SHARED)
else()
target_compile_definitions(app PRIVATE BUILD_XLSXIO_STATIC)
endif()
No, don't define BUILD_XLSXIO_SHARED
for the shared library, because that will define functions with dllexport
instead of dllimport
.
Only define BUILD_XLSXIO_STATIC
for static builds, nothing for shared builds.
Ok.. that brings me to:
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(app PRIVATE BUILD_XLSXIO_STATIC)
endif()
Thank you!
Hey!
I'm running into "fatal error LNK1120: 10 unresolved externals" when compiling and linking with MSVC 2019 using the vcpkg_target_triplet: x64-windows-static.
Error Message:
I've seen https://github.com/brechtsanders/xlsxio/issues/70, but that's no solution, because when building statically a
.def
file is not created.