RLAPI macro in Functions.hpp causes linking error when using MSVC + vcpkg
Closed this issue · 1 comments
The issue
The functions prefixed with the RLAPI macro in Functions.hpp cause a linking error.
raylib-cpp/include/Functions.hpp
Line 301 in f865785
Everything else works fine.
My setup
I use VS Studio 2022(MSVC) and vcpkg, which downloads, builds and links raylib on its own. I got raylib-cpp and included the header.
What causes the error
Vcpkg makes raylib use dynamic linking from the .dll by replacing a line:
https://github.com/microsoft/vcpkg/blob/7032c5759f823fc8699a5c37d5f7072464ccb9a8/ports/raylib/portfile.cmake#L81
In raylib.h:
Because of this the linker tries to import the wrapped functions marked with RLAPI from raylib.dll, which won't find.
I guess this error only exists when raylib is used with dynamic linkage, because raylib-cpp tests contain tests of these functions and they don't fail.
Solution
Changing the RLAPI macro to RLCPPAPI solves it for me, which basically changes __declspec(dllimport)
to static
.
So any reason not to change it in the lib aswell?
I believe we should likely move that function to a static class. It has always caused issues