在https://github.com/ocornut/imgui上它说:No specific build process is required. You can add the .cpp files to your existing project.
我尝试使用带有相关.cpp
文件的代码块,但是它给了我大约 500+ Undefined Reference to ... errors
。imgui.cpp
存在的第一个开始|1994|undefined reference to `ImGui::InputText(char const*, char*, unsigned long, int, int (*)(ImGuiInputTextCallbackData*), void*)'
。这是我尝试过的以下代码。
#include "imgui.h"
int main()
{
bool my_tool_active = true;
float my_color = 0.5;
// Create a window called "My First Tool", with a menu bar.
ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ }
if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; }
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
// Edit a color (stored as ~4 floats)
ImGui::ColorEdit4("Color", &my_color);
// Plot some values
const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values));
// Display contents in a scrolling region
ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
ImGui::BeginChild("Scrolling");
for (int n = 0; n < 50; n++)
ImGui::Text("%04d: Some text", n);
ImGui::EndChild();
ImGui::End();
return 0;
}
我错过了什么?我在网页上找不到任何链接器命令(根据我的经验,“未定义的引用...”通常是缺少链接器选项的结果)