0

I'm trying to compile SFML-Imgui in the Code::Blocks application, but I get errors. I have all the necessary Imgui files in the project directory, but what else do I need to do to fix the error?

../main.cpp:13: undefined reference to `ImGui::SFML::Init(sf::RenderWindow&, bool)'

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../main.cpp:22: undefined reference to `ImGui::SFML::ProcessEvent(sf::Event const&)'

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../main.cpp:26: undefined reference to `ImGui::SFML::Update(sf::RenderWindow&, sf::Time)'

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../main.cpp:31: undefined reference to `ImGui::SFML::Render(sf::RenderWindow&)'

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../main.cpp:35: undefined reference to `ImGui::SFML::Shutdown()'

Code:

#include <SFML/Graphics.hpp>
#include <iostream>

#include <imgui.h>
#include <imgui-SFML.h>

using namespace std;
using namespace sf;

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 800), "Test");
    ImGui::SFML::Init(window);
    sf::Clock dClock;
    while (window.isOpen()){
        sf::Event event;
        while (window.pollEvent(event))
        {
            ImGui::SFML::ProcessEvent(event);
            if (event.type == sf::Event::Closed)
                window.close();
        }
        ImGui::SFML::Update(window, dClock.restart());
        window.clear();
        sf::CircleShape shape(100);
        shape.setFillColor(sf::Color::Green);
        window.draw(shape);
        ImGui::SFML::Render(window);
        window.display();
    }

    ImGui::SFML::Shutdown();
    return 0;
}

Bru
  • 11
  • 1
  • Your bug is how you are linking. We can't help spot a problem in what you did because you did not show the settings you added to link. – drescherjm Feb 26 '23 at 15:01

0 Answers0