So beheben Sie den Fehler: Mehrfachdefinition von „GuiEnable“?C++

Programme in C++. Entwicklerforum
Anonymous
 So beheben Sie den Fehler: Mehrfachdefinition von „GuiEnable“?

Post by Anonymous »

Ich habe Probleme beim Konfigurieren von raygui.h mit cmake unter Verwendung von zwei Zielen, einer Bibliothek und einer ausführbaren Datei. Hier gibt es ein Repository mit den genauen Dateien, die während des Builds Fehler bei der Mehrfachdefinition von SomeFunction verursachen. Die Fehler lauten wie folgt:

Code: Select all

/usr/bin/ld: libgame-lib.a(hello_world.cpp.o): in function `GuiEnable':
hello_world.cpp:(.text+0x0): multiple definition of `GuiEnable'; CMakeFiles/exe.dir/src/main.cpp.o:main.cpp:(.text+0x0): first defined here
Es ist, als ob die raygui.h-Deklaration alle zweimal gemacht wurde.
Das Problem tritt nicht im Master-Zweig auf, wo nur ein Ziel direkt mit raygui.h verknüpft ist.
Dies sind die Dateien im Zweig, bei dem das Problem auftritt:

Code: Select all

// hello_world.hpp
// ----------------------------------------------------------------------------
#include "raylib.h"

#define RAYGUI_IMPLEMENTATION
#include "raygui.h"

void hello_world();
// ----------------------------------------------------------------------------

Code: Select all

// hello_world.cpp
// ----------------------------------------------------------------------------
#include "hello_world.hpp"

void hello_world() {
InitWindow(300, 300, "Hello World with raylib.");

while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(BLACK);
DrawText("Hello World", 120, 150, 12, RED);
GuiButton((Rectangle) {115, 180, 80, 16}, "Hello World");
EndDrawing();
}
}
// ----------------------------------------------------------------------------

Code: Select all

// main.cpp
// ----------------------------------------------------------------------------
#include "hello_world.hpp"

int main() {
hello_world();
return 0;
}
// ----------------------------------------------------------------------------

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post