Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vc17] Static SFML 3 + Static TGUI => unresolved external symbol __std_min_element_f #252

Closed
nerudaj opened this issue Feb 20, 2025 · 2 comments

Comments

@nerudaj
Copy link

nerudaj commented Feb 20, 2025

Description: I can't compile my program when I set both SFML and TGUI to use static libraries. The program compiles and executes succesfully when linked with dynamic libraries. I'd prefer static ones though since one has to copy all DLLs into their build folder and

System: Windows 10
Compiler: MSVC 17.9.2 (toolset v143)
CMake: 3.26.1

CMakeLists.txt:

cmake_minimum_required ( VERSION 3.26 )

project ( Repro )

set ( SFML_VERSION "3.0.0" )
set ( TGUI_VERSION "1.7.0")

include ( FetchContent )

FetchContent_Declare ( SFML
    URL "https://github.com/SFML/SFML/releases/download/${SFML_VERSION}/SFML-${SFML_VERSION}-windows-vc17-64-bit.zip"
    DOWNLOAD_EXTRACT_TIMESTAMP TRUE
    SOURCE_SUBDIR "does-not-exist" # Prevents MakeAvailable from calling add_subdirectory
)

FetchContent_Declare ( TGUI
    URL "https://github.com/texus/TGUI/releases/download/v${TGUI_VERSION}/TGUI-${TGUI_VERSION}-vc17-64bit-for-SFML-${SFML_VERSION}.zip"
    DOWNLOAD_EXTRACT_TIMESTAMP TRUE
    SOURCE_SUBDIR "does-not-exist" # Prevents MakeAvailable from calling add_subdirectory
)

FetchContent_MakeAvailable( SFML TGUI )

set ( SFML_STATIC_LIBRARIES ON )
find_package ( SFML
    ${SFML_VERSION} REQUIRED
    COMPONENTS Main Window Graphics
    PATHS "${sfml_SOURCE_DIR}/lib/cmake"
)

set ( TGUI_BACKEND SFML_GRAPHICS )
set ( TGUI_STATIC_LIBRARIES ON )
find_package ( TGUI 
    ${TGUI_VERSION} REQUIRED
    PATHS "${tgui_SOURCE_DIR}/lib/cmake"
)

add_executable( ${PROJECT_NAME} Main.cpp )
target_link_libraries( ${PROJECT_NAME} PRIVATE SFML::Main SFML::System SFML::Window TGUI::TGUI )

Main.cpp:

#include <TGUI/Backend/SFML-Graphics.hpp>
#include <TGUI/Tgui.hpp>
#include <SFML/Window.hpp>

int main(int, char* [])
{
	auto&& window = sf::RenderWindow(sf::VideoMode{ {1280, 720} }, "Repro", sf::State::Windowed);
	auto&& gui = tgui::Gui(window);

	while (window.isOpen())
	{
		while (const auto event = window.pollEvent())
		{
			if (event->is<sf::Event::Closed>()) window.close();
			gui.handleEvent(*event);
		}

		window.clear();

		gui.draw();

		window.display();
	}
}

Compiler diagnostic:

1>tgui-s-d.lib(unity_batch-4_cxx.obj) : error LNK2019: unresolved external symbol __std_min_element_f referenced in function "float const * __cdecl std::_Min_element_vectorized<float const >(float const * const,float const * const)" (??$_Min_element_vectorized@$$CBM@std@@YAPEBMQEBM0@Z)
1>tgui-s-d.lib(unity_batch-12_cxx.obj) : error LNK2001: unresolved external symbol __std_min_element_f
1>tgui-s-d.lib(unity_batch-4_cxx.obj) : error LNK2019: unresolved external symbol __std_max_element_f referenced in function "float const * __cdecl std::_Max_element_vectorized<float const >(float const * const,float const * const)" (??$_Max_element_vectorized@$$CBM@std@@YAPEBMQEBM0@Z)
1>C:\Users\jakub.neruda\Desktop\Repro\_build\Debug\Repro.exe : fatal error LNK1120: 2 unresolved externals
@texus
Copy link
Owner

texus commented Feb 20, 2025

Can you try updating your Visual Studio to the latest version (MSVC 17.13)?
It is possible that the TGUI libraries were built with a toolset newer than 17.9, which could cause errors like that.

@nerudaj
Copy link
Author

nerudaj commented Feb 20, 2025

Can you try updating your Visual Studio to the latest version (MSVC 17.13)? It is possible that the TGUI libraries were built with a toolset newer than 17.9, which could cause errors like that.

Good call. 17.12.2 on another computer works ok. And I naively thought that Microsoft maintains compatibility within a major version :/

@nerudaj nerudaj closed this as completed Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants