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

Author Topic: Trying to setup a project in CLion with CMake under MinGW  (Read 7009 times)

0 Members and 1 Guest are viewing this topic.

arcadiaq

  • Newbie
  • *
  • Posts: 5
    • View Profile
Trying to setup a project in CLion with CMake under MinGW
« on: April 16, 2015, 03:48:31 pm »
Hey there!
I'm trying to setup an SFML helloworld in CLion using CMake in Windows with MinGW, here's what I do:
The main.cpp is the standard
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Here's what my CMakeLists.txt looks like:
#Change this if you need to target a specific CMake version
cmake_minimum_required(VERSION 2.6)
set(PROJECT_NAME "MuspelheimR")
project(MuspelheimR)

# Enable debug symbols by default
if(CMAKE_BUILD_TYPE STREQUAL "")
  set(CMAKE_BUILD_TYPE Debug)
endif()
# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)

# Set version information in a config.h file
set(MuspelheimR_VERSION_MAJOR 1)
set(MuspelheimR_VERSION_MINOR 0)
configure_file(
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
  )
include_directories("${PROJECT_BINARY_DIR}")

# Define sources and executable
set(EXECUTABLE_NAME ${PROJECT_NAME})
add_executable(${EXECUTABLE_NAME} main.cpp)

# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
set(SEFML_ROOT "C:\\SFML-2.2")
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()

# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)

# CPack packaging
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR "${MuspelheimR_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${MuspelheimR_VERSION_MINOR}")
include(CPack)
The build is just fine, but when I launch the executable I get
Quote
"Process finished with exit code -1073741515 (0xC0000135)"
If I try to launch it manually the popup window says:
Quote
The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
What's wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #1 on: April 16, 2015, 03:51:17 pm »
set(SEFML_ROOT
I doubt that works just fine. ;D

If you had spent like 10s googling you'd have been informed that the error means, that it couldn't find the runtime libraries (not related to SFML).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

arcadiaq

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #2 on: April 16, 2015, 04:11:46 pm »
set(SEFML_ROOT
I doubt that works just fine. ;D

If you had spent like 10s googling you'd have been informed that the error means, that it couldn't find the runtime libraries (not related to SFML).

Well, I kind-of did, but I thought that might have something to do with how SFML treats some dependencies or something.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #3 on: April 16, 2015, 04:15:23 pm »
Unless you use one of the horrible TDM based MinGW compilers, the runtime libraries will be linked shared by default. And if you use the shared libraries of SFML they will link shared against the runtime libraries.
All you need to do is provide the runtime libraries' DLL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

arcadiaq

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #4 on: April 16, 2015, 04:19:35 pm »
Unless you use one of the horrible TDM based MinGW compilers, the runtime libraries will be linked shared by default. And if you use the shared libraries of SFML they will link shared against the runtime libraries.
All you need to do is provide the runtime libraries' DLL.

/removed set(SFML_ROOT)/

Alright, I'm using the standard MinGW one, not the TDM based version, so that shouldn't be an issue.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #5 on: April 16, 2015, 04:34:46 pm »
/removed set(SFML_ROOT)/
Why? My comment was pointing out your misspelling: SEFML_ROOT.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

arcadiaq

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #6 on: April 16, 2015, 04:42:57 pm »
/removed set(SFML_ROOT)/
Why? My comment was pointing out your misspelling: SEFML_ROOT.

It still finds SFML without specifying the path to it.

However, after copying all the libraries (SFML and non-SFML ones) into the folder with the executable I get following error:
Quote
The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz could not be located in the dynamic link library <path_to_executable>\sfml-system-d-2.dll
Googled it, several ppl have the same problems, seems like none of them have solved it.
« Last Edit: April 16, 2015, 04:47:55 pm by arcadiaq »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #7 on: April 16, 2015, 04:48:59 pm »
It still finds SFML without specifying the path to it.
Because CMake cached it... ::)

Googled it, several ppl have the same problems, seems like none of them have solved it.
You didn't look hard enough. It means you're mixing runtime libraries, which means that the SFML version you're using uses a different runtime library than the one you use for your application.
If you have downloaded SFML from this website, it will be incompatible with your "standard" MinGW version, we don't provide binaries for that compiler.
So you either use a matching compiler (e.g. this compiler with this package) or build from source.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

arcadiaq

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Trying to setup a project in CLion with CMake under MinGW
« Reply #8 on: April 16, 2015, 11:36:06 pm »
It still finds SFML without specifying the path to it.
Because CMake cached it... ::)

Googled it, several ppl have the same problems, seems like none of them have solved it.
You didn't look hard enough. It means you're mixing runtime libraries, which means that the SFML version you're using uses a different runtime library than the one you use for your application.
If you have downloaded SFML from this website, it will be incompatible with your "standard" MinGW version, we don't provide binaries for that compiler.
So you either use a matching compiler (e.g. this compiler with this package) or build from source.

Alright, thanks for help very much! It works now!

** and maybe sorry for dumb questions :D **