hello_imgui icon indicating copy to clipboard operation
hello_imgui copied to clipboard

Fali To Install By Vcpkg . it complain 5 LINK ERROR

Open whatagoodname opened this issue 11 months ago • 3 comments

INSTRUCTIONS

生成开始于 13:46... 1>------ 已启动生成: 项目: hello_imgui1, 配置: Debug x64 ------ 1>hello_imgui.lib(runner_factory.cpp.obj) : error LNK2019: 无法解析的外部符号 _Thrd_sleep_for,函数 "void __cdecl std::this_thread::sleep_until<struct std::chrono::steady_clock,class std::chrono::duration<__int64,struct std::ratio<1,1000000000> > >(class std::chrono::time_point<struct std::chrono::steady_clock,class std::chrono::duration<__int64,struct std::ratio<1,1000000000> > > const &)" (??$sleep_until@Usteady_clock@chrono@std@@V?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@23@@this_thread@std@@YAXAEBV?$time_point@Usteady_clock@chrono@std@@V?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@23@@chrono@1@@Z) 中引用了该符号 1>hello_imgui.lib(hello_imgui_font.cpp.obj) : error LNK2019: 无法解析的外部符号 __std_find_last_trivial_1,函数 "char const * __cdecl std::_Find_last_vectorized<char const ,char>(char const * const,char const * const,char)" (??$_Find_last_vectorized@$$CBDD@std@@YAPEBDQEBD0D@Z) 中引用了该符号 1>hello_imgui.lib(hello_imgui_font.cpp.obj) : error LNK2019: 无法解析的外部符号 __std_find_last_of_trivial_pos_1,函数 "unsigned __int64 __cdecl std::_Find_last_of_pos_vectorized<char,char>(char const * const,unsigned __int64,char const * const,unsigned __int64)" (??$_Find_last_of_pos_vectorized@DD@std@@YA_KQEBD_K01@Z) 中引用了该符号 1>hello_imgui.lib(whereami_cpp.cpp.obj) : error LNK2001: 无法解析的外部符号 __std_find_last_of_trivial_pos_1 1>hello_imgui.lib(hello_imgui_ini_settings.cpp.obj) : error LNK2019: 无法解析的外部符号 __std_search_1,函数 "char const * __cdecl std::_Search_vectorized<char const ,char const >(char const * const,char const * const,char const * const,unsigned __int64)" (??$_Search_vectorized@$$CBD$$CBD@std@@YAPEBDQEBD00_K@Z) 中引用了该符号 1>hello_imgui.lib(hello_imgui_ini_any_parent_folder.cpp.obj) : error LNK2001: 无法解析的外部符号 __std_search_1 1>hello_imgui.lib(functional_utils.cpp.obj) : error LNK2001: 无法解析的外部符号 __std_search_1 1>hello_imgui.lib(hello_imgui_ini_settings.cpp.obj) : error LNK2019: 无法解析的外部符号 __std_find_end_1,函数 "char const * __cdecl std::_Find_end_vectorized<char const ,char const >(char const * const,char const * const,char const * const,unsigned __int64)" (??$_Find_end_vectorized@$$CBD$$CBD@std@@YAPEBDQEBD00_K@Z) 中引用了该符号 1>F:\Project\WorkSpace\C++\VS\hello_imgui1\x64\Debug\hello_imgui1.exe : fatal error LNK1120: 5 个无法解析的外部命令 1>已完成生成项目“hello_imgui1.vcxproj”的操作 - 失败。 ========== 生成: 0 成功,1 失败,0 最新,0 已跳过 ========== ========== 生成 于 13:46 完成,耗时 02.334 秒 ==========

Describe the issue

MSBUILD complain 5 LINK ERROR: _Thrd_sleep_for __std_find_last_trivial_1 __std_find_last_of_trivial_pos_1 __std_search_1 __std_find_end_1 Version & Platform

My CPU is AMD 7900X,GPU 4060TI with latest driver using VS with latest version VS 2022 143v ,c++17 vcpkg install command is vcpkg install "hello-imgui[opengl3-binding,glfw-binding]", windows sdk 10(latest)

fail to build sln with #include "hello_imgui/hello_imgui.h" int main() { HelloImGui::Run( { ImGui::Text("Hello, world!"); ImGui::ShowDemoWindow(); }); }

whatagoodname avatar Mar 13 '25 05:03 whatagoodname

Please provide more details and format appearance of your question.

Did vcpkg install work, what commands did you run, etc

pthom avatar Mar 18 '25 13:03 pthom

My IDE is the latest version of Visual Studio. After executing the command vcpkg install "hello-imgui[opengl3-binding,glfw-binding]", and follow the command "vcpkg integrate install" after installed.

And I was able to use the ImGui and successfully run the code in main.cpp from the example_glfw_opengl3 sample solution. However, I am unable to successfully compile and link the following code:

#include "hello_imgui/hello_imgui.h"
int main(int, char* []) {
    HelloImGui::Run(
        [] { ImGui::Text("Hello, world!"); }, // Gui code
        "Hello!", true);                     // Window title + Window size auto
}

The following errors occurred: _1>hello_imgui.lib(runner_factory.cpp.obj) : error LNK2001: unresolved external symbol _Thrd_sleep_for 1>hello_imgui.lib(hello_imgui_font.cpp.obj) : error LNK2001: unresolved external symbol __std_find_last_trivial_1 1>hello_imgui.lib(hello_imgui_font.cpp.obj) : error LNK2001: unresolved external symbol __std_find_last_of_trivial_pos_1 1>hello_imgui.lib(whereami_cpp.cpp.obj) : error LNK2001: unresolved external symbol __std_find_last_of_trivial_pos_1 1>hello_imgui.lib(hello_imgui_ini_settings.cpp.obj) : error LNK2001: unresolved external symbol __std_search_1 1>hello_imgui.lib(hello_imgui_ini_any_parent_folder.cpp.obj) : error LNK2001: unresolved external symbol __std_search_1 1>hello_imgui.lib(functional_utils.cpp.obj) : error LNK2001: unresolved external symbol __std_search_1 1>hello_imgui.lib(hello_imgui_ini_settings.cpp.obj) : error LNK2001: unresolved external symbol _std_find_end_1

I installed both hello-imgui[opengl3-binding,glfw-binding] and hello-imgui[opengl3-binding,glfw-binding]:x64-windows-static. I also tried switching between the different versions of hello-imgui by toggling the "Use Static Library" option in Visual Studio. However, I encountered the same issue. I don't know why😭

the command of "vcpkg list" show:

egl-registry:x64-windows                          2024-01-25          EGL API and Extension Registry
egl-registry:x64-windows-static                   2024-01-25          EGL API and Extension Registry
glad:x64-windows                                  0.1.36              Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader...
glad:x64-windows-static                           0.1.36              Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader...
glad[gl-api-10]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-11]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-12]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-13]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-14]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-15]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-20]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-21]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-30]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-31]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-32]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-33]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-40]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-41]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-42]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[gl-api-43]:x64-windows                                           Imports extensions from OpenGL API specification...
glad[loader]:x64-windows                                              Generate loader logic.
glad[loader]:x64-windows-static                                       Generate loader logic.
glfw3:x64-windows                                 3.4#1               GLFW is a free, Open Source, multi-platform libr...
glfw3:x64-windows-static                          3.4#1               GLFW is a free, Open Source, multi-platform libr...
hello-imgui:x64-windows                           1.6.0#2             Hello ImGui: unleash your creativity in app deve...
hello-imgui:x64-windows-static                    1.6.0#2             Hello ImGui: unleash your creativity in app deve...
hello-imgui[glfw-binding]:x64-windows                                 Use GLFW platform backend (default)
hello-imgui[opengl3-binding]:x64-windows                              Use OpenGL3/ES2 renderer backend (default)
imgui:x64-windows                                 1.91.8#4            Bloat-free Immediate Mode Graphical User interfa...
imgui:x64-windows-static                          1.91.8#4            Bloat-free Immediate Mode Graphical User interfa...
imgui[docking-experimental]:x64-windows                               Build with docking support
imgui[docking-experimental]:x64-windows-static                        Build with docking support
imgui[glfw-binding]:x64-windows                                       Make available GLFW binding
imgui[glfw-binding]:x64-windows-static                                Make available GLFW binding
imgui[opengl3-binding]:x64-windows                                    Make available OpenGL3/ES/ES2 (modern) binding
imgui[opengl3-binding]:x64-windows-static                             Make available OpenGL3/ES/ES2 (modern) binding
nlohmann-json:x64-windows                         3.11.3#1            JSON for Modern C++
nlohmann-json:x64-windows-static                  3.11.3#1            JSON for Modern C++
opengl-registry:x64-windows                       2024-02-10#1        OpenGL, OpenGL ES, and OpenGL ES-SC API and Exte...
opengl-registry:x64-windows-static                2024-02-10#1        OpenGL, OpenGL ES, and OpenGL ES-SC API and Exte...
stb:x64-windows                                   2024-07-29#1        public domain header-only libraries
stb:x64-windows-static                            2024-07-29#1        public domain header-only libraries
vcpkg-cmake-config:x64-windows                    2024-05-23
vcpkg-cmake:x64-windows                           2024-04-23

whatagoodname avatar Mar 20 '25 09:03 whatagoodname

I just tried this:

Save main.cpp

#include "hello_imgui/hello_imgui.h"
int main(int, char* []) {
    HelloImGui::Run(
        [] { ImGui::Text("Hello, world!"); }, // Gui code
        "Hello!", true);                     // Window title + Window size auto
}

Save CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

project(HelloWorld)

set(CMAKE_CXX_STANDARD 17)
find_package(hello-imgui CONFIG REQUIRED)
hello_imgui_add_app(main main.cpp)
target_link_libraries(main PRIVATE hello-imgui::hello_imgui)

Install vcpkg

git clone https://github.com/microsoft/vcpkg.git 
cd vcpkg; .\bootstrap-vcpkg.bat  
 .\vcpkg install "hello-imgui[opengl3-binding,glfw-binding]:x64-windows"  
cd ..

Run build

mkdir build; cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=C:/.../vcpkg/scripts/buildsystems/vcpkg.cmake 
cmake --build .

And it worked.

I'm afraid there is not much more I can do to help.

However, I would advise you to try and solve the issue with CMake instead of inside visual studio project options.

find_package(Threads REQUIRED)
target_link_libraries(your_target PRIVATE Threads::Threads)

Other than that ChatGPT might perhaps have some good advices: https://chatgpt.com/share/67dc001c-432c-8004-8264-9cc1f6b74e68

pthom avatar Mar 20 '25 11:03 pthom