SFML_FOUND to FALSE so package "SFML" is considered to be NOT FOUND.
tsMezotic opened this issue · 5 comments
Just as the Title says, SFML_FOUND to FALSE so package "SFML" is considered to be NOT FOUND.
It happens when I was building Imgui-SFML: cmake <ImGui-SFML repo folder> -DIMGUI_DIR=<ImGui repo folder> -DSFML_DIR=<path with built SFML>
And where exactly does SFML_DIR point to?
And where exactly does SFML_DIR point to?
C:\ExternalLibraries\SFML\lib\cmake\SFML
It's where the SFMLConfig.cmake file is located.
Then you probably have different configurations with the current compiler compared to what was used with the compiler to build SFML.
For example 32bits vs 64bits or debug vs release or dynamic vs static
Issue has been fixed, decided to just download it with vcpkg...
but I keep getting this error now when I build it with CMake
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl sf::Window::setMouseCursorVisible(bool)" (__
imp_?setMouseCursorVisible@Window@sf@@QEAAX_N@Z) referenced in function "void __cdecl ImGui::SFML::Update(class sf::RenderWindow &,class sf::Time)" (?Update@SFML@ImGui
@@YAXAEAVRenderWindow@sf@@VTime@4@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl sf::Window::setMouseCursor(class sf::Cursor
const &)" (__imp_?setMouseCursor@Window@sf@@QEAAXAEBVCursor@2@@Z) referenced in function "void __cdecl ImGui::SFML::Update(class sf::RenderWindow &,class sf::Time)" (?
Update@SFML@ImGui@@YAXAEAVRenderWindow@sf@@VTime@4@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl sf::Window::hasFocus(void)const " (__imp_?ha
sFocus@Window@sf@@QEBA_NXZ) referenced in function "public: __cdecl `anonymous namespace'::WindowContext::WindowContext(class sf::Window const *)" (??0WindowContext@?A
0x78992566@@QEAA@PEBVWindow@sf@@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct HWND__ * __cdecl sf::Window::getSystemHandle(void)
const " (__imp_?getSystemHandle@Window@sf@@QEBAPEAUHWND__@@XZ) referenced in function "void __cdecl ImGui::SFML::SetCurrentWindow(class sf::Window const &)" (?SetCurre
ntWindow@SFML@ImGui@@YAXAEBVWindow@sf@@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class sf::Vector2<int> __cdecl sf::Mouse::getPosit
ion(class sf::Window const &)" (__imp_?getPosition@Mouse@sf@@SA?AV?$Vector2@H@2@AEBVWindow@2@@Z) referenced in function "void __cdecl ImGui::SFML::Update(class sf::Ren
derWindow &,class sf::Time)" (?Update@SFML@ImGui@@YAXAEAVRenderWindow@sf@@VTime@4@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
ImGui-SFML.lib(imgui-SFML.cpp.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class sf::Vector2<int> __cdecl sf::Touch::getPosit
ion(unsigned int,class sf::Window const &)" (__imp_?getPosition@Touch@sf@@SA?AV?$Vector2@H@2@IAEBVWindow@2@@Z) referenced in function "void __cdecl ImGui::SFML::Update
(class sf::RenderWindow &,class sf::Time)" (?Update@SFML@ImGui@@YAXAEAVRenderWindow@sf@@VTime@4@@Z) [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSDK.vcxproj]
C:\Users\Mezo\Documents\Projects\CoreSDK\Build\Release\CoreSDK.exe : fatal error LNK1120: 6 unresolved externals [C:\Users\Mezo\Documents\Projects\CoreSDK\Build\CoreSD
K.vcxproj]
CMake File:
cmake_minimum_required(VERSION 3.21)
project(CoreSDK LANGUAGES CXX)
include(FetchContent)
file(GLOB_RECURSE SRC_FILES "src/*.cpp")
set(ImGui-SFML_DIR "C:\\vcpkg\\packages\\imgui-sfml_x64-windows\\share\\ImGui-SFML")
set(imgui_DIR "C:\\vcpkg\\packages\\imgui_x64-windows\\share\\imgui")
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
FetchContent_MakeAvailable(SFML)
add_executable(CoreSDK ${SRC_FILES})
find_package(imgui REQUIRED)
find_package(ImGui-SFML REQUIRED)
include_directories("C:\\vcpkg\\installed\\x64-windows\\lib")
target_link_libraries(CoreSDK PRIVATE
sfml-system
sfml-window
sfml-graphics
sfml-network
sfml-audio
imgui::imgui
ImGui-SFML::ImGui-SFML
)
target_compile_features(CoreSDK PRIVATE cxx_std_17)
if (WIN32 AND BUILD_SHARED_LIBS)
add_custom_command(TARGET CoreSDK POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:CoreSDK> $<TARGET_FILE_DIR:CoreSDK> COMMAND_EXPAND_LISTS)
endif()
install(TARGETS CoreSDK)
@Mezo-hx, please see my example project on how to use ImGui-SFML with FetchContent.
In particular, you need to set IMGUI_SFML_FIND_SFML
to OFF
for everything to work. (you're adding SFML target to your build via FetchContent_MakeAvailable
, so ImGui-SFML doesn't need to call find_package(SFML)
)