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

Author Topic: MinGW Linking undefined reference to __imp__  (Read 1505 times)

0 Members and 1 Guest are viewing this topic.

Fedron

  • Newbie
  • *
  • Posts: 1
    • View Profile
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.
« Last Edit: January 14, 2021, 01:45:42 pm by Fedron »