Cannot compile
Opened this issue · 7 comments
I cannot compile newest version from master. system is Linux, OpenSUSE Leap 15. everything related to SDL is installed to compile it.
[ 43%] Built target D2Client
[ 44%] Building CXX object CMakeFiles/game.dir/Game/Audio_SDL.cpp.o
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:34:79: error: macro "Log_WarnAssertReturn" requires 2 arguments, but only 1 given
Log_WarnAssertReturn(SDL_GetNumAudioDevices(false) >= pConfig->dwAudioDevice);
^
In file included from /home/khazakar/OpenD2/Game/Diablo2.hpp:2:0,
from /home/khazakar/OpenD2/Game/Audio_SDL.hpp:2,
from /home/khazakar/OpenD2/Game/Audio_SDL.cpp:1:
/home/khazakar/OpenD2/Game/../Shared/D2Shared.hpp:691:80: warning: 'visibility' attribute ignored [-Wattributes]
typedef D2EXPORT D2ModuleExportStrc* (*GetAPIType)(D2ModuleImportStrc* pImports);
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp: In function 'void Audio_SDL::Init(OpenD2ConfigStrc*)':
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:21:72: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_SYSTEMINFO, "SDL_Mixer init...\n");
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:22:79: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_SYSTEMINFO, "Enumerate audio devices:\n");
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:26:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_SYSTEMINFO, "Device %d: %s\n", i, szDeviceName);
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:34:3: error: 'Log_WarnAssertReturn' was not declared in this scope
Log_WarnAssertReturn(SDL_GetNumAudioDevices(false) >= pConfig->dwAudioDevice);
^~~~~~~~~~~~~~~~~~~~
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:35:124: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_MESSAGE, "Output Device: %s\n", SDL_GetAudioDeviceName(pConfig->dwAudioDevice, false));
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:41:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Warning(__FILE__, __LINE__, "Could not open audio device.");
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:41:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/khazakar/OpenD2/Game/Audio_SDL.cpp: In function 'sfx_handle Audio_SDL::RegisterSound(char*)':
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:129:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Warning(__FILE__, __LINE__, "Ran out of free sound space.");
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:129:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:143:81: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_MESSAGE, "Failed to load %s", szAudioPath);
^
In file included from /home/khazakar/OpenD2/Game/Audio_SDL.hpp:2:0,
from /home/khazakar/OpenD2/Game/Audio_SDL.cpp:1:
/home/khazakar/OpenD2/Game/Diablo2.hpp:722:76: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
#define Log_WarnAssert(x) if(!(x)) { Log::Warning(__FILE__, __LINE__, "" #x); }
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:148:3: note: in expansion of macro 'Log_WarnAssert'
Log_WarnAssert(sdlFile);
^~~~~~~~~~~~~~
/home/khazakar/OpenD2/Game/Diablo2.hpp:722:76: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
#define Log_WarnAssert(x) if(!(x)) { Log::Warning(__FILE__, __LINE__, "" #x); }
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:148:3: note: in expansion of macro 'Log_WarnAssert'
Log_WarnAssert(sdlFile);
^~~~~~~~~~~~~~
/home/khazakar/OpenD2/Game/Audio_SDL.cpp: In function 'mus_handle Audio_SDL::RegisterMusic(char*)':
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:160:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Warning(__FILE__, __LINE__, "Ran out of free sound space.");
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:160:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:174:81: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Log::Print(OpenD2LogFlags::PRIORITY_MESSAGE, "Failed to load %s", szAudioPath);
^
In file included from /home/khazakar/OpenD2/Game/Audio_SDL.hpp:2:0,
from /home/khazakar/OpenD2/Game/Audio_SDL.cpp:1:
/home/khazakar/OpenD2/Game/Diablo2.hpp:722:76: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
#define Log_WarnAssert(x) if(!(x)) { Log::Warning(__FILE__, __LINE__, "" #x); }
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:179:3: note: in expansion of macro 'Log_WarnAssert'
Log_WarnAssert(sdlFile);
^~~~~~~~~~~~~~
/home/khazakar/OpenD2/Game/Diablo2.hpp:722:76: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
#define Log_WarnAssert(x) if(!(x)) { Log::Warning(__FILE__, __LINE__, "" #x); }
^
/home/khazakar/OpenD2/Game/Audio_SDL.cpp:179:3: note: in expansion of macro 'Log_WarnAssert'
Log_WarnAssert(sdlFile);
^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/game.dir/build.make:76: CMakeFiles/game.dir/Game/Audio_SDL.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:110: CMakeFiles/game.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Thank you for your report, I will look into it
Since 6fe704e it compile but on archlinux I had a link issue
/usr/bin/ld: CMakeFiles/game.dir/Game/Renderer_SDL.cpp.o: undefined reference to symbol 'SDL_CreateTexture'
/usr/bin/ld: /usr/lib/libSDL2-2.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/game.dir/build.make:489: game] Error 1
make[1]: *** [CMakeFiles/Makefile2:110: CMakeFiles/game.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Looks like it's because SDL2_LIBRARIES
is empty (see archlinux issue #57972 and there)
If I replace SDL2_LIBRARIES
with SDL2::SDL2
it link and works, I have sound and can go to the select hero class (I guest for now it's the only thing you can do without a TCP/IP on 1.10). (using c220ddf)
Does making this change break other Linux distros?
I'm not sure, I will try some distros with lxc and let you know. It's probably due to the version of sdl, cmake or just related to archlinux.
Simply replacing it break Ubuntu.
Using a TARGET
check like they did here "cannot find sdl2" works for ubuntu, archlinux and opensuse.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 640e718..6ecacd6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,11 @@ if(BUILD_GAME)
set_target_properties(game PROPERTIES LINKER_LANGUAGE CXX)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
- target_link_libraries(game ${SDL2_LIBRARIES} SDL2_net SDL2_mixer m dl)
+ if (TARGET SDL2::SDL2)
+ target_link_libraries(game SDL2:SDL2 SDL2_net SDL2_mixer m dl)
+ else()
+ target_link_libraries(game ${SDL2_LIBRARIES} SDL2_net SDL2_mixer m dl)
+ endif()
endif()
target_compile_definitions(game PUBLIC D2EXE)
There is probably a cleaner way to do it
Ubuntu use
libsdl2-2.0-0:amd64 2.0.4+dfsg1-2ubuntu2
libsdl2-dev 2.0.4+dfsg1-2ubuntu2
libsdl2-mixer-2.0-0:amd64 2.0.1+dfsg1-1
libsdl2-mixer-dev:amd64 2.0.1+dfsg1-1
libsdl2-net-2.0-0:amd64 2.0.1+dfsg1-2
libsdl2-net-dev:amd64 2.0.1+dfsg1-2
cmake 3.5.1-1ubuntu3
While archlinux
sdl2 2.0.9-1
sdl2_mixer 2.0.4-1
sdl2_net 1:2.0.1-2
cmake 3.13.1-1
And opensuse
S | Name | Type | Version | Arch | Repository
---+---------------------------+---------+-------------------+--------+-----------
i+ | libSDL2-2_0-0 | package | 2.0.8-lp150.1.1 | x86_64 | repo-oss name: libSDL2-2_0-0
i+ | libSDL2-devel | package | 2.0.8-lp150.1.1 | x86_64 | repo-oss name: libSDL2-devel
i+ | libSDL2_mixer-2_0-0 | package | 2.0.2-lp150.1.3 | x86_64 | repo-oss name: libSDL2_mixer-2_0-0
i+ | libSDL2_mixer-devel | package | 2.0.2-lp150.1.3 | x86_64 | repo-oss name: libSDL2_mixer-devel
i+ | libSDL2_net-2_0-0 | package | 2.0.0-lp150.1.3 | x86_64 | repo-oss name: libSDL2_net-2_0-0
i+ | libSDL2_net-devel | package | 2.0.0-lp150.1.3 | x86_64 | repo-oss name: libSDL2_net-devel
i+ | cmake | package | 3.10.2-lp150.1.5 | x86_64 | repo-oss name: cmake
Hi have installed the same and not work :
/usr/bin/ld : ne peut trouver -lSDL2:SDL2
collect2: erreur: ld a retourné le statut de sortie 1
make[2]: *** [CMakeFiles/game.dir/build.make:489: game] Error 1
make[1]: *** [CMakeFiles/Makefile2:79: CMakeFiles/game.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
CMakeLists.txt
Have compile on fedora for fix
But is not possible to create player