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

Author Topic: Audio not working with GCC 7.3.0 MinGW (DW2) - 32-bit  (Read 9200 times)

0 Members and 1 Guest are viewing this topic.

SpaceMax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Audio not working with GCC 7.3.0 MinGW (DW2) - 32-bit
« on: December 19, 2020, 02:02:22 pm »
Hey everyone, I'm trying to develop my first game with SFML and everything is going fine so far. Now, I wanted to add the first sound effects, but Im not able to get it running. Somehow, it is not working for me. I created a new hello world project, but also in this project the program crashes.

From this page https://www.sfml-dev.org/download/sfml/2.5.1/ I downloaded "GCC 7.3.0 MinGW (DW2) - 32-bit" and also the linked GCC compiler (https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-posix/dwarf/i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z/download). So the toolchain setup should be okay, also everything else (regarding game's graphic animations) is running fine.

Here my main.cpp:

//main.cpp
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main() {

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

    // !! just by adding this sound object the program crashes !!
    // when I remove the line the "hello world" sfml app runs fine
    sf::Sound sound;

    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 my CMakeLists.txt:

cmake_minimum_required(VERSION 3.11)
project(untitled1)
add_executable(untitled1 main.cpp)

set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "C:/Users/Maximilian/Documents/Projects/toolchain/SFML-2.5.1/lib/cmake/SFML")

find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED)
target_link_libraries(untitled1 sfml-graphics sfml-audio)

When I run the program I directly get:

Process finished with exit code -1073741515 (0xC0000135)

I'm using windows 10 and clion as IDE.

So, Im kinda stuck now and do not know how to proceed. Can anyone help me here? Am I missing some linking in the cmake? I tried to search the forum, but did not find anything on this. Any help is appreciated :)
« Last Edit: December 19, 2020, 02:03:58 pm by SpaceMax »

SpaceMax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Audio not working with GCC 7.3.0 MinGW (DW2) - 32-bit
« Reply #1 on: December 19, 2020, 07:24:31 pm »
I now copied openal32.dll to my output directory and now it works. Is this documented somewhere that we sometimes have to manually copy .dll files to the output directory? 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Audio not working with GCC 7.3.0 MinGW (DW2) - 32-bit
« Reply #2 on: December 19, 2020, 08:13:55 pm »
Quote
Is this documented somewhere that we sometimes have to manually copy .dll files to the output directory?
At the end of the "Getting started" tutorial. Moreover, knowing how shared libraries work (how they are loaded by the OS) -- which is not very complicated -- is something that every developer should know.
Laurent Gomila - SFML developer