kidrigger/godot-videodecoder

-L flag missing?

Closed this issue · 3 comments

When I try to build with the instructions in the readme it cannot find the shared lib files.

jpate@ca-jpate-nb:~/Documents/escaperoom/contrib/godot-videodecoder$ scons -Q platform=x11 | grep avformat
gcc -o bin/x11/libgdnative_videodecoder.so -shared -Wl,-rpath=\$ORIGIN/lib/ src/gdnative_videodecoder.os -Lbin/x11 -lavformat -lavcodec -lavutil -lswscale -lswresample
/usr/bin/ld: cannot find -lavformat
/usr/bin/ld: cannot find -lavcodec
/usr/bin/ld: cannot find -lavutil
/usr/bin/ld: cannot find -lswscale
/usr/bin/ld: cannot find -lswresample
collect2: error: ld returned 1 exit status
scons: *** [bin/x11/libgdnative_videodecoder.so] Error 1

I added env.Append(SHLINKFLAGS=['-Lthirdparty/lib']) to SConstruct in the x11 section and it was able to build.

Am I doing something wrong here?
I have pulled ffmpeg and godot-videodecoder into my project using git submodules

contrib
├── ffmpeg
├── godot-videodecoder
...

The command to build ffmpeg was

cd contrib/ffmpeg
./configure --enable-shared --enable-version3 --disable-programs \
    --enable-libvorbis --enable-libvpx \
    --enable-opencl --enable-opengl --disable-debug \
    --prefix=../godot-videodecoder/thirdparty && \
make && make install

The -lavformat option is looking for avformat in your system's lib directory and the same for the other libraries ld can't find. The -L flag is adding a folder for ld to look for your libraries. Since you installed FFmpeg with --prefix=../godot-videodecoder/thirdparty, that is where the FFmpeg lib files are and why adding the -L flag worked.

The SConstruct file works fine for me since I installed FFmpeg through my system package manager but will not work if you follow the FFmpeg install instructions listed in the readme, as you found out. Removing the --prefix option should install FFmpeg to your system directory and allow you to build FFmpeg without adding the -L flag. Alternatively, since you're on linux, just use your system package manager to install FFmpeg. The readme should be updated to reflect one of these two options @kidrigger.

It's a regression in the SCons file I think, since it's supposed to copy from the third-party folder and then link. But yes, it seems I have missed to do a system installed option. I'll get it done soon!

Ideally this works with a custom build of ffmpeg that links all it's dependencies statically. I don't think linking against system libraries is a viable long term strategy.

I'm working on that now since you can't rely on the user to have them installed on their system can you?

With --disable-everything, --enable-vp9 and --enable-opus I've got the whole thing down to 5mb! See https://github.com/jamie-pate/ffmpeg-static/blob/master/build.sh#L284

I think it should also be convenient to cross compile this? Which means each platform's dependencies should also be stored in a separate directory: https://github.com/jamie-pate/godot-videodecoder/blob/master/SConstruct#L13

Still shaking this all out in my fork...