Skip to content

RLAPI macro in Functions.hpp causes linking error when using MSVC + vcpkg #273

@Zentrom

Description

@Zentrom

The issue

The functions prefixed with the RLAPI macro in Functions.hpp cause a linking error.

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:
Képkivágás
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions