raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.26k stars 280 forks source link

Multiple definitions of raygui functions #409

Open Vi-dot1 opened 1 month ago

Vi-dot1 commented 1 month ago

I've been having problems implementing raygui 4 in my current raylib project in C++, each time I try to build it the terminal shows several lines like this for several functions inside raygui.h:

[build] C:/path../to../project../src/raygui.h:2839: multiple definition of `GuiValueBox'; CMakeFiles\RayDraw.dir/objects.a(gui.cpp.obj):C:/path../to../project../src/raygui.h:2839: first defined here

And so on for multiple Gui functions.

I implemented raygui on its own header file kind of like this:

#pragma once
/* gui.h */

extern "C"{
    #include"raylib.h"

    #define RAYGUI_IMPLEMENTATION
    #include"raygui.h"
}

void drawGui();

And a source file where I include the header and define the draw function. I tried changing RAYGUI_IMPLEMENTATION to RAYGUI_STATIC but that just makes makes the functions invisible to the compiler


I'm not sure if this is related, but I'm also getting a bunch of warnings about enum mismatches:

enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]

They seem to come from different places in raygui.h from these calls, which return values from two different enums depending on the result:

GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR))

That should probably go on its own issue, but I saying it here just in case is somehow related to my problem

Futuremappermydud commented 1 month ago

This is so Confusing!!! The Readme says you only need to define RAYGUI_IMPLEMENTATION once yet half the functions are only defined under RAYGUI_IMPLEMENTATION... Aghhhh!!!!