Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Fedron

Pages: [1]
1
General / MinGW Linking undefined reference to __imp__
« on: January 14, 2021, 09:48:59 am »
Hi,

I'm trying to link SFML using CMake but I keep on getting undefined references when building the project.

D:/Repositories/SFMLTest/main.cpp:17: undefined reference to `__imp__ZN2sf5ColorC1Ehhhh'
D:/Repositories/SFMLTest/main.cpp:17: undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
D:/Repositories/SFMLTest/main.cpp:18: undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
(There are more than in the code snippet but they all give the same undefined error)

My CMakeLists.txt looks like this

cmake_minimum_required(VERSION 3.17)
project(SFMLTest)

set(CMAKE_CXX_STANDARD 14)

set(SFML_DIR "SFML/lib/cmake/SFML")
set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)

include_directories("SFML/include")

add_executable(SFMLTest main.cpp)
target_link_libraries(SFMLTest ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})

This is an empty project with the SFML equivalent of "Hello, world!" in main.cpp


I've tried building SFML myself to make sure that the compiled version matches my version of the MinGW compiler but that has been giving the same errors. I also tried using the MSVC compiler and version but that also didn't work and gave the same errors.

I've also tried linking both dynamic and static versions of SFML but they also both give the same error. At this point I'm pretty sure I've tried everything I could find on the internet about this but nothing seemed to fix this issue for me.

Pages: [1]