Compiling against modified library in linux - compilation

I've compiled mplayer2 against the prebuilt libavcodec library in ubuntu. It crashes under specific conditions.
Judging my the error message spat out, the problem lies with libavcodec. So what I would like to is do experiment with some of the libavcodec code. i.e. Compile my own version of libavcodec and then compile mplayer2 against that.
pkg-config will point towards the installed libavcodec libraries from ubuntu's apt-get. How do I point it to my own version of libavcodec? Or tell the configure script to use my version?

Related

Can not build ffmpeg with gpu acceleration on macOS

I'm trying to use my GPU for video encoding/decoding operations on macOS.
OS: MacOS 10.12.5 (Sierra) //hackintosh if it matters
CUDA Toolkit 8.0 installed
NVidia GTX 1080 with latest web driver
Followed this guides:
https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX
https://developer.nvidia.com/ffmpeg
Config:
./configure --enable-cuda --enable-cuvid --enable-nvenc \
--enable-nonfree --enable-libnpp \
--extra-cflags=-I/Developer/NVIDIA/CUDA-8.0/include \
--extra-ldflags=-L/Developer/NVIDIA/CUDA-8.0/lib
Got this error:
ERROR: cuvid requested, but not all dependencies are satisfied: cuda
config.log - full configure log
I did not install Video Codec SDK (not sure how to make it on macOS, just thought that it may come with cuda toolkit) and according to this page I have a lot of limitations on OSX.
Is it possible on macOS? Or this will work only for linux/windows?

ffmpeg libswresample.so.2 needed by libavcodec.so not found

I have locally built ffmpeg library, but I am unable to link them in my program.
I have tried CMAKE_INSTALL_RPATH, but libswresample still cannot be found.
Strangely all the libraries libswresample, libavcodec etc etc are all in the same folder ( /local/git/PSG/libs/ffmpeg/../ffmpeg-install/lib/ ) . libavcodec is found, but not the libswresample.
So, I fail to understand why is gcc complaining?
I am using target_link_libraries( ) to link the ffmpeg libraries.
What am I doing wrong?
/usr/bin/ld: warning: libswresample.so.2, needed by /local/git/PSG/libs/ffmpeg/../ffmpeg-install/lib/libavcodec.so, not found (try using -rpath or -rpath-link)
The problem was that the libswresample.so.2 was taken from the system path. Unfortunately, all the libs generated by ffmpeg have to be explicitly linked in the target_link_libraries(). By explicitly giving the absolute path of libswresample for example by
find_library(libswresample_path NAMES libswresample PATH "the/path/to/your/libresample"),
the problem was solved

How can I detect ffmpeg vs libav in CMake?

My project uses libavformat to connect to rtsp:// URLs. It's important that it set a socket timeout and reconnect on error. Unfortunately, the stimeout open option for this only exists in ffmpeg (and in particular, its libavformat versions >= 55.1.100), not the competing project libav (any version). And some systems I'd like to support (such as Raspbian Jessie) are still bundled with libav.
So, I think my best option is to detect whether I have a suitable version using cmake, and install ffmpeg in-tree if not. I think I should be able to do this via something like:
pkg_check_modules(FFMPEG libavutil libavcodec libavformat)
if(not FFMPEG_FOUND or FFMPEG_VERSION VERSION_LESS 55.1.101)
ExternalProject_Add(
FfmpegProject
URL "http://ffmpeg.org/releases/ffmpeg-2.8.3.tar.xz"
URL_HASH "SHA1=a6f39efe1bea9a9b271c903d3c1dcb940a510c87"
INSTALL_COMMAND "")
...set up flags and such to use this in-tree version...
endif()
except that I don't know how to detect libav vs ffmpeg. I don't see anything in the pkgconfig stuff or libavformat/version.h to distinguish them. The version numbers they use seem to overlap. It's not obvious to me at all how to tell the difference programmatically, much less do so with a not-weird cmake rule. Any ideas?
To specifically answer your question, use this code:
#include <stdio.h>
#include "libavutil/opt.h"
#include "libavformat/avformat.h"
int main(int argc, char *argv[]) {
av_register_all();
AVInputFormat *input = av_find_input_format("rtsp");
const AVClass *klass = input->priv_class;
const AVOption *opt = av_opt_find2(&klass, argv[1], NULL, 0, AV_OPT_SEARCH_FAKE_OBJ, NULL);
printf("%p\n", opt);
return 0;
}
This can do runtime detection, and here's how it works:
bash-3.2$ /tmp/test hi
0x0
bash-3.2$ /tmp/test stimeout
0x103420100
For your other question, detecting Libav vs. FFmpeg can be done by looking at the library micro version. For FFmpeg, they all start at 100 (e.g. libavformat 55.1.100), whereas for Libav, they start at 0. So if micro < 100, it's Libav, else it's FFmpeg. To get libavformat micro version at runtime, use avformat_version() & 0xff, or LIBAVFORMAT_VERSION_MICRO at compile time.

Is `--enable-mpbsd` no longer required when building GMP?

So I'm trying to build a cross-compiler toolchain off of the latest GCC (gcc-5.1.0). GCC requires GMP and so I downloaded GNU MP 6.0 (gmp-6.0.0).
Instructions for building GMP suggest (for my purpose) to pass the parameter --enable-mpbsd which is documented as follows:
The meaning of the new configure options:
--enable-cxx
This parameter enables C++ support
--enable-mpbsd
This builds the Berkeley MP compatibility library
However, when I fun configure, it warns me:
configure: WARNING: unrecognized options: --enable-mpbsd
Which suggests that the option was introduced in 5.x and deprecated again in 6.x or replaced by something else ...?!
The exact command line I use is (just for completeness):
./configure --prefix=$PREFIX --enable-shared --enable-static --enable-mpbsd --enable-fft --enable-cxx --host=x86_64-pc-freebsd6
PS: for now I intend to disregard this warning and proceed anyway. I'll report back whether this still turns out as a functional toolchain.
--enable-mpbsd
This builds the Berkeley MP compatibility library
This was potentially useful 20 years ago, but it hasn't been for a long time, which is why it was removed from GMP. Linux From Scratch is wrong to recommend the use of that option, it was never required (though it didn't hurt). Please contact them so they can update their instructions.
By the way, you do not need --enable-shared --enable-static --enable-fft, they are the default.

Integrating Octave interpreter into program compiled with GCC 4.8.1

I'm trying to integrate Octave interpreter into my rigid body simulator compiled with GCC 4.8.1.
Following steps posted in the official documentation (https://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html) allow me to compile, link, and successfully execute the first example. Note, that I can link the executable with both mkoctfile.exe, or g++ when minGW 4.8.1 is added to PATH.
However, the second example showing how to embed the interpreter into my program compiles, links, and then segfaults on execution when GCC 4.8.1 binaries are in PATH. It works, when I use the supplied compiler (in my case it's gcc 4.6.2 shipped with octave 3.6.1 on windows).
Do I need to build octave from source using GCC 4.8.1 in order to successfully link program compiled using that version, or is there any other way to do so?
Using GCC 4.6.2 is not an option for me, as my program uses c++11 features not present in that version.
I just learned that there is a newer Octave version available at http://mxeoctave.osuv.de/ which was compiled with GCC 4.9.2. This version of GCC works for me perfectly and the second example provided in the documentation started to work when compiled with g++ provided with the distribution.

Resources