-
Notifications
You must be signed in to change notification settings - Fork 106
Description
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
RLAPI inline std::string TextSubtext(const std::string& text, int position, int length) { |
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?