I linked SFML and imgui, and I get no errors, but when I run I get errors like
undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
This is my cmake:
cmake_minimum_required(VERSION 3.22)
project(ImGuiT)
set(CMAKE_CXX_STANDARD 20)
add_executable(ImGuiT main.cpp
imgui/imgui_widgets.cpp
imgui/imgui.cpp
imgui/imgui-SFML.cpp
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imconfig.h
imgui/imstb_rectpack.h
imgui/imstb_textedit.h
imgui/imstb_truetype.h
imgui/imconfig-SFML.h
imgui/imgui-SFML.h
imgui/imgui-SFML_export.h
imgui/imgui_internal.h
imgui/imgui.h)
include_directories(headers /usr/include c:/SFML/include imgui)
set(SFML_ROOT c:/SFML)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(ImGuiT ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})
# Copy dlls to build
if(WIN32)
file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")
file(COPY ${MINGW_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()
I use sfml that I linked from drive and imgui files are in folder in project. I guess the imgui-sfml can't see sfml, but I linked that, so I don't know how to link it properly I also added
#include "imconfig-SFML.h"
to the imconfig.h for imgui to see sfml extension
And this is just a simple test main that I can't run:
#include "imgui.h"
#include "imgui-SFML.h"
#include "SFML/Graphics.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Window Title");
ImGui::SFML::Init(window);
bool circleExists = true;
float circleRadius = 200.0f;
int circleSegments = 100;
float circleColor[3] = { (float)204 / 255, (float)77 / 255, (float)5 / 255 };
sf::CircleShape shape(circleRadius, circleSegments);
shape.setFillColor(sf::Color
(
(int)(circleColor[0] * 255),
(int)(circleColor[1] * 255),
(int)(circleColor[2] * 255)
)); // Color circle
shape.setOrigin(circleRadius, circleRadius);
shape.setPosition(400, 400); // Center circle
sf::Clock deltaClock;
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, deltaClock.restart());
ImGui::Begin("Window title");
ImGui::Text("Window text!");
ImGui::Checkbox("Circle", &circleExists);
ImGui::SliderFloat("Radius", &circleRadius, 100.0f, 300.0f);
ImGui::SliderInt("Sides", &circleSegments, 3, 150);
ImGui::ColorEdit3("Color Circle", circleColor);
ImGui::End();
shape.setRadius(circleRadius);
shape.setOrigin(circleRadius, circleRadius);
shape.setPointCount(circleSegments);
shape.setFillColor(sf::Color
(
(int)(circleColor[0] * 255),
(int)(circleColor[1] * 255),
(int)(circleColor[2] * 255)
)); // Color circle
window.clear(sf::Color(18, 33, 43)); // Color background
if (circleExists)
window.draw(shape);
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
return 0;
}