zardoru / raindrop

yet another beatgame.
GNU General Public License v3.0
128 stars 16 forks source link

Fix compilation errors and warnings on Linux #62

Closed papatience closed 7 years ago

papatience commented 7 years ago

There remain some warnings, for example in src/LuaManager.cpp and src/VideoPlayback.cpp.

clang++ -o src/LuaManager.o -c -std=c++14 -O2 -DNDEBUG -fpermissive -DLINUX -DMP3_ENABLED -Isrc/ext -Isrc -Ilib/include/LuaBridge -Ilib/include/lua -Ilib/include/stb -Ilib/include/stdex -Ilib/include src/LuaManager.cpp
src/LuaManager.cpp:517:5: warning: implicit conversion from 'unsigned long' to 'int' changes value from
      18446744073709551615 to -1 [-Wconstant-conversion]
    luaL_newlib(State, Reg);
    ^~~~~~~~~~~~~~~~~~~~~~~
src/lauxlib.h:111:27: note: expanded from macro 'luaL_newlib'
#define luaL_newlib(L,l)        (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
                                 ^~~~~~~~~~~~~~~~~~~~~
src/lauxlib.h:109:50: note: expanded from macro 'luaL_newlibtable'
  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
  ~~~~~~~~~~~~~~~       ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
1 warning generated.

luaL_newlib() must be called with an array, not a pointer, so it can't be called with a function argument. However, the function calling it, RegisterLibrary(), isn't used.

clang++ -o src/VideoPlayback.o -c -std=c++14 -O2 -DNDEBUG -fpermissive -DLINUX -DMP3_ENABLED -Isrc/ext -Isrc -Ilib/include/LuaBridge -Ilib/include/lua -Ilib/include/stb -Ilib/include/stdex -Ilib/include src/VideoPlayback.cpp
src/VideoPlayback.cpp:144:20: warning: 'avpicture_get_size' is deprecated [-Wdeprecated-declarations]
                auto framesize = avpicture_get_size(AV_PIX_FMT_RGB24, w, h) + AV_INPUT_BUFFER_PADDING_SIZE;
                                 ^
lib/include/libavcodec/avcodec.h:5468:5: note: 'avpicture_get_size' has been explicitly marked deprecated here
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
    ^
src/VideoPlayback.cpp:152:4: warning: 'avpicture_fill' is deprecated [-Wdeprecated-declarations]
                        avpicture_fill((AVPicture*)avframe, buf, AV_PIX_FMT_RGB24, w, h);
                        ^
lib/include/libavcodec/avcodec.h:5453:5: note: 'avpicture_fill' has been explicitly marked deprecated here
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
    ^
src/VideoPlayback.cpp:182:4: warning: 'avcodec_decode_video2' is deprecated [-Wdeprecated-declarations]
                        avcodec_decode_video2(Context->UsableCodecCtx, Context->DecodedFrame, &gotframe, &packet);
                        ^
lib/include/libavcodec/avcodec.h:4812:5: note: 'avcodec_decode_video2' has been explicitly marked deprecated here
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
    ^
src/VideoPlayback.cpp:195:3: warning: 'av_free_packet' is deprecated [-Wdeprecated-declarations]
                av_free_packet(&packet);
                ^
lib/include/libavcodec/avcodec.h:4473:6: note: 'av_free_packet' has been explicitly marked deprecated here
void av_free_packet(AVPacket *pkt);
     ^
src/VideoPlayback.cpp:234:31: warning: 'codec' is deprecated [-Wdeprecated-declarations]
                if (newctx->AV->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
                                            ^
lib/include/libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked deprecated here
    AVCodecContext *codec;
                    ^
src/VideoPlayback.cpp:236:47: warning: 'codec' is deprecated [-Wdeprecated-declarations]
                        newctx->CodecCtx = newctx->AV->streams[i]->codec;
                                                                   ^
lib/include/libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked deprecated here
    AVCodecContext *codec;
                    ^
src/VideoPlayback.cpp:251:6: warning: 'avcodec_copy_context' is deprecated [-Wdeprecated-declarations]
        if (avcodec_copy_context(newctx->UsableCodecCtx, newctx->CodecCtx) != 0) {
            ^
lib/include/libavcodec/avcodec.h:4241:5: note: 'avcodec_copy_context' has been explicitly marked deprecated here
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
    ^
src/VideoPlayback.cpp:261:11: warning: 'avpicture_get_size' is deprecated [-Wdeprecated-declarations]
        auto f = avpicture_get_size(newctx->UsableCodecCtx->pix_fmt, 
                 ^
lib/include/libavcodec/avcodec.h:5468:5: note: 'avpicture_get_size' has been explicitly marked deprecated here
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
    ^
src/VideoPlayback.cpp:273:2: warning: 'avpicture_fill' is deprecated [-Wdeprecated-declarations]
        avpicture_fill((AVPicture*)avframe, buf, ucc->pix_fmt, w, h);
        ^
lib/include/libavcodec/avcodec.h:5453:5: note: 'avpicture_fill' has been explicitly marked deprecated here
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
    ^
9 warnings generated.

These are just warnings about deprecated functions.

I've changed the compiler to clang++ because g++ fails to compile the source files. It uses up 100 % of the CPU and blocks there.

raindrop will compile on Linux with this pull request, but there are runtime errors left to fix.

zardoru commented 7 years ago

Oh man! I inmediately grabbed my computer when I saw the email for this pull request. I'm really sorry to say that I can't merge this into master, not without going through every change myself, because I've done further development on the future branch, and master is almost severely behind the future branch. If you're willing to bring your changes into that branch, I'll be more than happy to take the changes.

Oh, in addition, if you do report the runtime errors, I can definitely help go through them. I'll be more than happy to do that.

papatience commented 7 years ago

I've brought the changes into future.

Pressing a key at the startup screen causes the raindrop to crash:

raindrop ver: 0.500 Aug  1 2017 start.
Working directory: /home/paul/src/github.com/papatience/raindrop
sqlite: table diffdb has 15 columns but 16 values were supplied (code 1)
sqlite: no such column: genre (code 1)
sqlite: no such column: genre (code 1)
sqlite: no such column: genre (code 1)
Initializing... 
LuaManager: Running script GameData/Skins/default/skin.lua.
GLFW succesfully initialized.
GLFW Error 65539: Invalid joystick -1
Setting up shaders...System supports VAOs...
Default Vertex Shader Compiled Succesfully
Fragment Shader Compiled succesfully
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
[librocket:4] Loading Lua interpreter
[librocket:4] Loaded font face Togoshi Gothic Regular (from font.ttf).
Total Initialization Time: 0.527740s
LuaManager: Running script GameData/Skins/default/mainmenu.lua.
Compiling fragment shader.
Fragment Shader Compiled Succesfully
Shader linking succesful.
libpng warning: iCCP: known incorrect sRGB profile
[librocket:3] Unable to open file ScreenMainMenu.rml.
Time: 0.090510s
[librocket:3] Invalid property declaration at :0
[librocket:3] Invalid property declaration at :0
ScreenSelectMusic.rml succesfully loaded.
Started loading songs..
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::directory_iterator::construct: No such file or directory
Aborted

With master, raindrop would crash if it didn't find the directory songs in the current directory, but now it crashes whether songs is present or not.

Edit: Ok, we need to specify the songs directory in config.ini. When I do so, it no longer crashes. However, it won't find any songs I put in the directory.

zardoru commented 7 years ago

Allow me to merge this in first, and I request that you do a followup issue. It still shouldn't crash, and I'm going to address that now.