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

Author Topic: undefined reference to `_imp___ZN2sf5MusicC1Ev'?  (Read 3712 times)

0 Members and 1 Guest are viewing this topic.

Rellot

  • Newbie
  • *
  • Posts: 4
    • View Profile
undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« on: February 27, 2022, 07:36:45 am »
Hello there, first time posting an issue here

I'm using gcc tdm 5.1.0(code::blocks 17.12) using SFML 2.4.2

 sf::Music music;
 // Load from File and Print an error message
 if (!music.openFromFile("040.wav")){
    std::cout << "this sh*t failed to load" << std::endl;
 }
 music.play();
 

while buliding it gives me this weird error
||=== Build: Debug in old_project (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
undefined reference to `_imp___ZN2sf5MusicC1Ev'|
undefined reference to `_imp___ZN2sf5Music12openFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'|
undefined reference to `_imp___ZN2sf11SoundStream4playEv'|
undefined reference to `_imp___ZN2sf5MusicD1Ev'|
undefined reference to `_imp___ZN2sf5MusicD1Ev'|
||error: ld returned 1 exit status|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 4 second(s)) ===|
 

seraching it gives me an issue of linking but all my linkings are correct
and so as version numbers match.
I tried loading pictures on the window and fonts, they work fine.
but it doesn't work on audio and music. anyone knows what's going on?
« Last Edit: April 09, 2022, 08:22:52 am by Rellot »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #1 on: February 28, 2022, 11:13:37 am »
Reads like you didn't link the sfml-audio module.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rellot

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #2 on: April 04, 2022, 09:41:25 am »
Sorry for late reply.

Reads like you didn't link the sfml-audio module.

Well, I did.
and Someone from discord suggested me to compile from source
So I tried compiling from source. while generating through Cmake I got this warning:

Code: [Select]
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (VORBIS)
  does not match the name of the calling package (Vorbis).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindVorbis.cmake:19 (find_package_handle_standard_args)
  src/SFML/Audio/CMakeLists.txt:73 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
Taking a wild guess that warning is related to audio as Vorbis is general-purpose compressed audio format.

when building the SFML project, it gives me a warning that auto_ptr is deprecated

Code: [Select]
||=== Build: all in SFML (compiler: GNU GCC Compiler) ===|
SFML-2.4.2\src\SFML\Audio\AudioDevice.cpp|110|warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]|
MinGW\lib\gcc\mingw32\10.3.0\include\c++\bits\unique_ptr.h|57|note: declared here|
SFML-2.4.2-sources\SFML-2.4.2\src\SFML\Audio\AudioDevice.cpp|128|warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]|
MinGW\lib\gcc\mingw32\10.3.0\include\c++\bits\unique_ptr.h|57|note: declared here|

and still the same exact error remained. I've already checked to make sure whether the linkings were correct or not
« Last Edit: April 04, 2022, 09:44:49 am by Rellot »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #3 on: April 04, 2022, 10:38:07 am »
The mentioned warnings were already fixed in the up coming SFML 2.6 release, check the 2.6.x branch.

Either way, if you get the same error, I'd still have to guess that you didn't link sfml-audio
Can you provide the linker command that is used to link your application?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rellot

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #4 on: April 09, 2022, 08:22:28 am »
The mentioned warnings were already fixed in the up coming SFML 2.6 release, check the 2.6.x branch.

I can see that but while compiling the sfml-window target, it gave a lot of errors:
Code: [Select]
||=== Build: sfml-window in SFML (compiler: GNU GCC Compiler) ===|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1477|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1477|error: 'struct IDirectInputEffect' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1538|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1538|error: 'struct IDirectInputDeviceA' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1567|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1567|error: 'struct IDirectInputDeviceW' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1642|error: base class 'struct IDirectInputDeviceA' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1642|error: 'struct IDirectInputDevice2A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1681|error: base class 'struct IDirectInputDeviceW' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1681|error: 'struct IDirectInputDevice2W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1786|error: base class 'struct IDirectInputDevice2A' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1786|error: 'struct IDirectInputDevice7A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1828|error: base class 'struct IDirectInputDevice2W' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1828|error: 'struct IDirectInputDevice7W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1943|error: base class 'struct IDirectInputDevice7A' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1943|error: 'struct IDirectInputDevice8A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1989|error: base class 'struct IDirectInputDevice7W' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|1989|error: 'struct IDirectInputDevice8W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2155|error: extra ';' [-Werror=pedantic]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2163|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2163|error: 'struct IDirectInputA' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2182|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2182|error: 'struct IDirectInputW' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2225|error: base class 'struct IDirectInputA' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2225|error: 'struct IDirectInput2A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2246|error: base class 'struct IDirectInputW' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2246|error: 'struct IDirectInput2W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2295|error: base class 'struct IDirectInput2A' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2295|error: 'struct IDirectInput7A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2318|error: base class 'struct IDirectInput2W' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2318|error: 'struct IDirectInput7W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2375|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2375|error: 'struct IDirectInput8A' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2397|error: base class 'struct IUnknown' has accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2397|error: 'struct IDirectInput8W' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]|
SFML-2.6.x\extlibs\headers\mingw\dinput.h|2464|error: extra ';' [-Werror=pedantic]|
src\SFML\Window\CMakeFiles\sfml-window.dir\build.make|135|recipe for target 'src/SFML/Window/CMakeFiles/sfml-window.dir/EglContext.cpp.obj' failed|
CMakeFiles\Makefile2|253|recipe for target 'src/SFML/Window/CMakeFiles/sfml-window.dir/all' failed|
CMakeFiles\Makefile2|260|recipe for target 'src/SFML/Window/CMakeFiles/sfml-window.dir/rule' failed|
SFML-2.6.x\bulid\src\SFML\Window\Makefile|185|recipe for target 'src/SFML/Window/CMakeFiles/sfml-window.dir/rule' failed|
||=== Build failed: 40 error(s), 0 warning(s) (0 minute(s), 14 second(s)) ===|


and yes, I've checked the complier to GCC TDM 5.1.0

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #5 on: April 16, 2022, 02:39:00 pm »
Maybe your TDM copy has an incompatible dinput header, so not really sure what's going on here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rellot

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: undefined reference to `_imp___ZN2sf5MusicC1Ev'?
« Reply #6 on: June 28, 2022, 07:11:22 pm »
update: I upgraded from tdm gcc to gcc 11.3.0 and the issue with dinput.h. so it was probably an issue on your end.

so I still waited for some commits and then i updated the branch till this commit
https://github.com/SFML/SFML/commit/6d1e4286402ce91b53febc7193866906caa49598
and the build was successful. Had no issues or warning whatsoever. Will test the audio, gotta sleep lt's already past 12!
« Last Edit: June 28, 2022, 07:12:59 pm by Rellot »