M
M
Michael2020-12-29 18:11:29
MinGW
Michael, 2020-12-29 18:11:29

Why can't I link .cpp files to my SFML project?

I write in VS Code, a project with SFML ImGui, without ImGui the project compiles, but not with ImGui.
I connected imgui according to this guide - here

My code in Makefile

all: clean compile link

clean:	
  cls del *.o

compile:
  g++ -c *.cpp  -ISFMLImGui/include -ISFMLImGui/include/ImGui -ISFMLImGui/include/ImGui/imgui-sfml-master               

link:
  g++ *.o -o main.exe -LSFMLImGui/lib -lsfml-graphics -lsfml-window -lsfml-system -lopengl32 -lfreeglut


When I try to build the project, I get "undefined reference" /*freeglut and opengl32 errors, I included */
The imgui.cpp files and so on do not lie in the root of the project, I did not put them there, because when compiling with them, even more errors appear

error log

g++ *.o -o main.exe -LSFMLImGui/lib -lsfml-graphics -lsfml-window -lsfml-system -lopengl32 -lfreeglut
main.o:main.cpp:(.text+0x147e): undefined reference to `ImGui::SetNextWindowPos(ImVec2 const&, int, ImVec2 const&)'
main.o:main.cpp:(.text+0x14ab): undefined reference to `ImGui::SetNextWindowSize(ImVec2 const&, int)'
main.o:main.cpp:(.text+0x180c): undefined reference to `ImDrawList::AddRectFilled(ImVec2 const&, ImVec2 const&, unsigned int, float, int)'
main.o:main.cpp:(.text+0x1847): undefined reference to `ImGui::SetCursorPos(ImVec2 const&)'
main.o:main.cpp:(.text+0x187a): undefined reference to `ImGui::SameLine(float, float)'
main.o:main.cpp:(.text+0x1886): undefined reference to `ImGui::TextDisabled(char const*, ...)'
main.o:main.cpp:(.text+0x1a73): undefined reference to `ImGui::CreateContext(ImFontAtlas*)'
main.o:main.cpp:(.text+0x1a81): undefined reference to `ImGui::SFML::Init(sf::RenderWindow&, bool)'
main.o:main.cpp:(.text+0x1acf): undefined reference to `ImGui::SFML::UpdateFontTexture()'
main.o:main.cpp:(.text+0x1b0f): undefined reference to `ImGui::SFML::Shutdown()'
main.o:main.cpp:(.text+0x77dd): undefined reference to `ImGui::EndChild()'
main.o:main.cpp:(.text+0x77e2): undefined reference to `ImGui::End()'
main.o:main.cpp:(.text+0x77f5): undefined reference to `ImGui::SFML::Render(sf::RenderTarget&)'

Screenshot of the project

5feb4705421ca110027748.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-12-29
@LoganFromBH

The files imgui.cpp and so on are not in the root of the project, I did not put them there, because when compiling with them, even more errors appear

And where do you think the functions are implemented ImGui::SetNextWindowPos, ImGui::SetNextWindowSizeetc.?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question