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

Author Topic: mingw32-make not registering SFML (Windows 10, CLion)  (Read 1847 times)

0 Members and 1 Guest are viewing this topic.

undertilted

  • Newbie
  • *
  • Posts: 2
    • View Profile
mingw32-make not registering SFML (Windows 10, CLion)
« on: March 28, 2022, 03:29:10 am »
I'm trying to get started with SFML, and to get everything started I'm doing an incredibly simple program:
#include <iostream>
#include <SFML/Window.hpp>

int main() {
    sf::Time t1 = sf::seconds(0.01f);
    return 0;
}
 

But lots of problems are coming up with linking things. When I try to run this program, I get this error:
CMakeFiles\MY_PROJECT.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/usr/CLionProjects/[...]/MY_PROJECT/main.cpp:6: undefined reference to `__imp__ZN2sf7secondsEf'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\MY_PROJECT.dir\build.make:106: MY_PROJECT.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:95: CMakeFiles/MY_PROJECT.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:102: CMakeFiles/MY_PROJECT.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:137: MY_PROJECT] Error 2

Here as much info about relevant files/folders/configs and their contents/locations/etc as I can think of:

CMakeLists.txt
(Top level of project directory)
cmake_minimum_required(VERSION 3.17)
project(MY_RPOJECT)

set(CMAKE_CXX_STANDARD 14)

add_executable(MY_PROJECT main.cpp)

set(SFML_ROOT C:/[...]/SFML-2.5.1)
include_directories(C:/[...]/SFML-2.5.1/include)
find_package(SFML REQUIRED audio graphics window network system)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")

if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(MY_PROJECT ${SFML_LIBRARIES})
endif()

# file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})

if(WIN32)
    file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/.../bin/*.dll")
    file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()

FindSFML.cmake
(in both "cmake-modules" folder which is at top level of project directory and in C:\Program Files\CMake\share\cmake-3.22\Modules)
[Contents not shown]

Make: C:\Program Files\mingw64\bin\mingw32-make.exe
C++ Compiler: C:\Program Files\mingw64\bin\g++.exe

Running cmake:
Ran in the top level directory of my project
Source code: The top level directory of my project
Where to build binaries: cmake-build (folder in top level directory of my project)

PATHS:
Environmental variable paths are linked up to
1) The root folder of my SFML directory
2) bin folder in my SFML directory
3) Root folder of mingw64
4) bin folder of mingw64

SFML info:
SFML-2.5.1
GCC 7.3.0 MinGW (DW2) - 32-bit have tried this with 64 bit too, exact same error
TDM 5.1.0 (32-bit), MinGW Builds 7.3.0 (32-bit), MinGW Builds 7.3.0 (64-bit) taken directly from SFML download page


The issue I'm running into is trying to make SFML, I have been trying to follow the documentation/tutorial for setting it up for a while but I'm new to this and can't get it working.

The tutorial says that I have to run
cmake -G"MinGW Makefiles" ./build
although I'm a) not sure where to run it and b) it throws a "/build directory not found" error whenever I try it

When running cmake (as per SFML tutorial, I'm doing cmake-gui) and I hit "configure", it doesn't show up with any SFML variables, even though it says it should on the tutorial. It finishes configuring with only CMAKE_BUILD_TYPE, CMAKE_GNUtoMS, CMAKE_INSTALL_PREFIX, and SFML_INCLUDE_DIR coming up as variables. I can hit generate and it successfully generates, but running the project throws the aforementioned error.

Any help would be very appreciated! I am at a complete loss

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: mingw32-make not registering SFML (Windows 10, CLion)
« Reply #1 on: March 28, 2022, 08:15:50 am »
Check out the CMake Migration Guide.

You need to link SFML with sfml-graphics etc. and not with ${SFML_LIBRARIES}.
Neither do you have to manually specify the include directory for SFML
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

undertilted

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: mingw32-make not registering SFML (Windows 10, CLion)
« Reply #2 on: March 28, 2022, 04:31:54 pm »
ERROR CODE 0xC0000135 NOW OCCURRING

Thank you, so much, this helped a lot!
However, now I'm running into a "Process finished with exit code -1073741515 (0xC0000135)" error when running the program.
I've done research into the problem and it seems that it has to do with some sort of incompatibility, but I don't know where it might be occurring. From another post, I will include all info I think may be necessary:

CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(Everything)

set(CMAKE_CXX_STANDARD 14)

add_executable(Everything main.cpp)

set(SFML_DIR "C:/Hub/Coding/Libraries/SFML_32/SFML-2.5.1/lib/cmake/SFML")
set(SFML_DOC_DIR "C:/Hub/Coding/Libraries/SFML_32/SFML-2.5.1/doc")
find_package(SFML 2.5.1 COMPONENTS audio graphics window network system REQUIRED)

target_link_libraries(Everything sfml-audio sfml-graphics sfml-window sfml-network sfml-system)

gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/TDM-GCC-32/bin/../libexec/gcc/mingw32/5.1.0/lto-wrapper.exe
Target: mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=mingw32 --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --disable-symvers --enable-cxx-flags='-fno-function-sections -fno-data-sections -DWINPTHREAD_STATIC' --prefix=/mingw32tdm --with-local-prefix=/mingw32tdm --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm-1)

- Windows 10 64-bit machine
- CLion 2020.2.5
- SFML 2.5.1
- GCC 7.3.0 MinGW (DW2) - 32-bit
- mingw32
     (This error also occurs when using mingw32 and SFML: GCC 7.3.0 MinGW (SEH) - 64-bit)
- cmake-gui recognizes all SFML variables
     (All connected to the GCC 7.3.0 MinGW (DW2) - 32-bit SFML version)
- SFML_DIR and SFML_DOC_DIR are also set to same values within CMakeCache.txt



Any ideas either a) where the incompatibility is, or b) is something else is the issue?
Thank you so much in advance for any help you can give!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: mingw32-make not registering SFML (Windows 10, CLion)
« Reply #3 on: March 28, 2022, 07:21:41 pm »
If do a web search for the error, you'll quickly find out, that it's a missing DLL error, meaning that you need to copy the MinGW runtime and SFML libraries next to your executable.
Unfortunately CLion hides the more common MsgBox popup provided by Windows
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything