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?
The issue
The functions prefixed with the RLAPI macro in Functions.hpp cause a linking error. https://github.com/RobLoach/raylib-cpp/blob/f865785fee2cb18da6ad6a9012a2993a73f2a2b1/include/Functions.hpp#L301 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)
tostatic
. So any reason not to change it in the lib aswell?