@LoganFromBH
15 лет

Почему я не могу слинковать .cpp файлы с своим проектом SFML?

Я пишу в VS Code, проект с SFML ImGui, без ImGui проект компилится, но с ImGui - нет.
Подключал imgui по вот этому гайду - вот
Мой код в 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


При попытке построить проект появляются ошибки "undefined reference" /*freeglut и opengl32 я подключил */
Файлы imgui.cpp и тд не лежат в корне проекта, я их туда не положил, потому-что при компиляции с ними появляется ещё больше ошибок

лог ошибок

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&)'

Скрин проекта

5feb4705421ca110027748.png
  • Вопрос задан
  • 247 просмотров
Решения вопроса 1
jcmvbkbc
@jcmvbkbc
"I'm here to consult you" © Dogbert
Файлы imgui.cpp и тд не лежат в корне проекта, я их туда не положил, потому-что при компиляции с ними появляется ещё больше ошибок

А где по-твоему реализованы функции ImGui::SetNextWindowPos, ImGui::SetNextWindowSize и т.д.?
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы