Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cassado10

Pages: [1]
1
General / Im having trouble compiling SFML & ImGui
« on: August 07, 2023, 05:45:40 pm »
 I'm following the tutorial here:https://terminalroot.com/how-to-create-graphical-interfaces-with-dear-imgui-and-sfml/

    My Code looks like this:

#include "include/imgui.h"
#include "include/imgui-SFML.h"

#include<SFML/Graphics.hpp>

int main(){
    //Window Initialize
    sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
    window.setFramerateLimit(60);
   
    //Initialize ImGui
    ImGui::SFML::Init(window);

    //shape in SFML
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Cyan);


    sf::Clock deltaClock;
    while (window.isOpen())
    {
        //Event Handling
        sf::Event event;
        while (window.pollEvent(event))
        {
            ImGui::SFML::ProcessEvent(window, event);

            if (event.type == sf::Event::Closed)
                window.close();
        }
        ImGui::SFML::Update(window, deltaClock.restart());

        ImGui::Begin("Hello World!");
        ImGui::Button("Look at this pretty button");
        ImGui::End();

        window.clear();
        window.draw(shape);
        ImGui::SFML::Render(window);
        window.display();
    }

    ImGui::SFML::Shutdown();
}

    2. And to compile i used the following commands using Mingw:

//the compiling part went ok

g++ -c main.cpp -IC:/SFML-2.5.1/include

//the linking part didn&#39;t work

g++ main.o -o app -LC:/SFML-2.5.1/lib -lsfml-graphics -lsfml-window -lsfml-system

    3. I get this following error:

main.o:main.cpp:(.text+0x137): undefined reference to `ImGui::SFML::Init(sf::RenderWindow&, bool)&#39;
main.o:main.cpp:(.text+0x1c5): undefined reference to `ImGui::SFML::ProcessEvent(sf::Window const&, sf::Event const&)&#39;
main.o:main.cpp:(.text+0x203): undefined reference to `ImGui::SFML::Update(sf::RenderWindow&, sf::Time)&#39;
main.o:main.cpp:(.text+0x21a): undefined reference to `ImGui::Begin(char const*, bool*, int)&#39;
main.o:main.cpp:(.text+0x247): undefined reference to `ImGui::Button(char const*, ImVec2 const&)&#39;
main.o:main.cpp:(.text+0x24c): undefined reference to `ImGui::End()&#39;
main.o:main.cpp:(.text+0x2ca): undefined reference to `ImGui::SFML::Render(sf::RenderWindow&)&#39;
main.o:main.cpp:(.text+0x2e7): undefined reference to `ImGui::SFML::Shutdown()&#39;
collect2.exe: error: ld returned 1 exit status

Any help is appreciated.

I'm not sure if these details are useful but:

    I'm using VSCode with Mingw (my laptop goes reeeeally slow if i use Visual Studio 19)

    SFML-2.5.1

    Imgui 1.88 from https://github.com/ocornut/imgui (as shown on the link)

    Imgui-sfml from https://github.com/eliasdaler/imgui-sfml (as shown on the link)

    If i'm missing anything please let me know.

Some of my secondary questions are:

    Do i need to link any .a or .dll files just like i have to do in sfml?

    I've seen other sites mention something about linking opengl. How do i do that?

    Is there another way to create a project without having to copy the files into my project file? Something like doing that whole process in C:/ and later add the default include path to VSCode preferences?

Pages: [1]
anything