I did some changes to /libavformat/concat.c in the FFmpeg source.
There I included libcurl.
Internet says I have to add the following code to 'Makefile'.
INCLUDE = -I/usr/local/include
LDFLAGS = -L/usr/local/lib
LDLIBS = -lcurl
That did not work.
I use this to build FFmpeg:
make clean && ./configure --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libx264 && make -j 4
Error:
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libavformat.a(concat.o): In function `concat_read':
/root/ffmpeg_sources/ffmpeg/libavformat/concat.c:151: undefined reference to `curl_easy_init'
/root/ffmpeg_sources/ffmpeg/libavformat/concat.c:155: undefined reference to `curl_easy_setopt'
/root/ffmpeg_sources/ffmpeg/libavformat/concat.c:156: undefined reference to `curl_easy_perform'
/root/ffmpeg_sources/ffmpeg/libavformat/concat.c:158: undefined reference to `curl_easy_getinfo'
original Makefile:
https://github.com/FFmpeg/FFmpeg/blob/master/Makefile
Can you help me?
Use this to configure FFmpeg:
./configure --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags='-I/usr/local/include' --extra-ldflags='-L/usr/local/lib -lcurl'
Don't mess with the Makefile, FFmpeg's build system isn't quite standard and simple as most typical opensource projects' Makefiles.
Related
My aim is to compile zlib alongside my application files, I use gcc from tdm-gcc and have cloned the repository https://github.com/madler/zlib
in /example there is a zpipe.c file which utilizes the library but I can't seem to get it compiling on windows.
I've added -lz to the end of my compile command and I receive /x86_64-w64-mingw32/bin/ld.exe: cannot find -lz error.
If I try to compile with just -Izlib I end up with these errors:
$ gcc -Izlib zpipe.c -o zpipe
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x6a): undefined reference to `deflateInit_'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0xca): undefined reference to `deflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x12e): undefined reference to `deflate'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x1be): undefined reference to `deflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x23c): undefined reference to `deflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x2c0): undefined reference to `inflateInit_'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x320): undefined reference to `inflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x36f): undefined reference to `inflate'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x3d1): undefined reference to `inflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x440): undefined reference to `inflateEnd'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\[redacted]\AppData\Local\Temp\ccjXicsi.o:zpipe.c:(.text+0x474): undefined reference to `inflateEnd'
collect2.exe: error: ld returned 1 exit status
Any help is greatly appreciated! I've searched stack overflow and tried all the suggestions and also googled and I'm still having issues.
The errors seem trivial and I've fixed such errors in the past, but this one I'm stuck on and I'm not sure what else to try.
1) Creating the static library.
Inside the zlib folder where the .c and .h files are located running gcc -c *.c will generate .o files that can be used to build the library.
after you have the .o files, running ar -rc libz.a *.o will generate a libz.a file, this will allow you to link via -lz
2) Compiling zpipe.c into zpipe.exe
put zpipe.c into the folder where libz.a is located, this is for simplicity when compiling.
running gcc -L. zpipe.c -o zpipe.exe -lz will create zpipe.exe.
3) Quick demo
Create a file hello.txt with Hello World! inside.
Run ./zpipe.exe < hello.txt > output.txt this will inflate the data in hello.txt and put it in output.txt
Run ./zpipe.exe -d < output.txt > original.txt to decompress the file and you will see Hello World! inside original.txt
Definitions
-L. tells gcc to use the current folder for the header files.
-lz tells gcc to compile with a static library who's name starts with lib and ends in .a for eg. libexample.a would be -lexample
When using MSYS2 shell it's quite simple, just run the following commands (replace /usr/local with the desired location):
INSTALLPREFIX=/usr/local
wget -c http://www.zlib.net/zlib-1.2.12.tar.gz
tar xfz zlib-1.2.12.tar.gz
cd zlib-1.2.12
make -f win32/Makefile.gcc install \
SHARED_MODE=1 \
INCLUDE_PATH=$INSTALLPREFIX/include \
LIBRARY_PATH=$INSTALLPREFIX/lib \
BINARY_PATH=$INSTALLPREFIX/bin
I am trying to build a JNI shared library which statically links to ffmpeg.
But at the linking stage, gcc fails with the following error:
/usr/bin/ld: ./lib_lin64/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
I am using the following commands to compile my jni library:
gcc -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I ./include -fPIC -c *.c
gcc -shared -Wl,--no-undefined -o libnv_avc_dec.so *.o -Wl,-Bstatic -L./lib_lin64 -lavcodec -lavutil -lswresample -lswscale -Wl,-Bdynamic -lm
And I only use h264 decoding feature, so I am also building ffmpeg from source with the minimal required feature set. The ./configure command I use is:
./configure \
--enable-pic --prefix=ffmpeg-dist \
--disable-debug --enable-version3 --enable-gpl \
--disable-everything --enable-hwaccel=h264_vdpau --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_qsv --enable-hwaccel=h264_mmal \
--enable-decoder=h264 --enable-decoder=h264_vdpau --enable-decoder=h264_crystalhd --enable-decoder=h264_mmal --enable-decoder=h264_qsv \
--disable-iconv --disable-securetransport --disable-xlib --disable-zlib --disable-lzma --disable-bzlib --disable-doc --disable-programs --disable-avformat --disable-avfilter --disable-postproc
So, as I understand, the linker tells me that ffmpeg should be compiled with -fPIC flag in order to make a shared library. But I believe that I've already done so by specifying the --enable-pic configure flag. And I am pretty much stuck here because I am not very familiar with autotools, nor with ffmpeg build process in particular.
If this is the issue of ffmpeg .a libs not being compiled with -fPIC flag, how can i force it? And if this is not the case, what am i doing wrong and how can i fix this error?
Environment details: Ubuntu 14.04.3 64-bit in Virtualbox, gcc 4.8.5 and 5.3 (both give the same results), ffmpeg v.2.8.5
If you're building a shared library but need to link with static ffmpeg libs add linker flags:
-Wl,-Bsymbolic
When using cmake:
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
I am trying to compile a C program, while linking the APR library.
I am getting the following error message:
cc -g -Wall -pthread -I/usr/local/apr/include/apr-1 -I/usr/local/apr/include/apr-util-1 -L/usr/local/apr/lib -L .aprutil-1 -L .apr-1 devpkg.c bstrlib.o db.o shell.o commands.o -o devpkg
/tmp/cczC53x5.o: In function `main':
/home/yotam/Dropbox/Development/C/devpkg/devpkg.c:14: undefined reference to `apr_pool_initialize'
/home/yotam/Dropbox/Development/C/devpkg/devpkg.c:15: undefined reference to `apr_pool_create_ex'
/home/yotam/Dropbox/Development/C/devpkg/devpkg.c:29: undefined reference to `apr_getopt_init'
/home/yotam/Dropbox/Development/C/devpkg/devpkg.c:31: undefined reference to `apr_getopt'
db.o: In function `DB_init':
/home/yotam/Development/C/devpkg/db.c:89: undefined reference to `apr_pool_initialize'
/home/yotam/Development/C/devpkg/db.c:90: undefined reference to `apr_pool_create_ex'
/home/yotam/Development/C/devpkg/db.c:93: undefined reference to `apr_dir_make_recursive'
/home/yotam/Development/C/devpkg/db.c:105: undefined reference to `apr_pool_destroy'
/home/yotam/Development/C/devpkg/db.c:109: undefined reference to `apr_pool_destroy'
shell.o: In function `Shell_exec':
/home/yotam/Development/C/devpkg/shell.c:16: undefined reference to `apr_pool_create_ex'
/home/yotam/Development/C/devpkg/shell.c:38: undefined reference to `apr_pool_destroy'
/home/yotam/Development/C/devpkg/shell.c:44: undefined reference to `apr_pool_destroy'
shell.o: In function `Shell_run':
/home/yotam/Development/C/devpkg/shell.c:55: undefined reference to `apr_procattr_create'
/home/yotam/Development/C/devpkg/shell.c:58: undefined reference to `apr_procattr_io_set'
/home/yotam/Development/C/devpkg/shell.c:62: undefined reference to `apr_procattr_dir_set'
/home/yotam/Development/C/devpkg/shell.c:65: undefined reference to `apr_procattr_cmdtype_set'
/home/yotam/Development/C/devpkg/shell.c:68: undefined reference to `apr_proc_create'
/home/yotam/Development/C/devpkg/shell.c:71: undefined reference to `apr_proc_wait'
commands.o: In function `Command_fetch':
/home/yotam/Development/C/devpkg/commands.c:44: undefined reference to `apr_uri_parse'
/home/yotam/Development/C/devpkg/commands.c:48: undefined reference to `apr_fnmatch'
/home/yotam/Development/C/devpkg/commands.c:51: undefined reference to `apr_fnmatch'
/home/yotam/Development/C/devpkg/commands.c:70: undefined reference to `apr_fnmatch'
/home/yotam/Development/C/devpkg/commands.c:78: undefined reference to `apr_dir_make_recursive'
/home/yotam/Development/C/devpkg/commands.c:84: undefined reference to `apr_fnmatch'
/home/yotam/Development/C/devpkg/commands.c:90: undefined reference to `apr_dir_make_recursive'
collect2: error: ld returned 1 exit status
make: *** [devpkg] Error 1
Here is my makefile, it should be able to compile on different computers, where the PREFIX variable is the location relative to the computer.
(this program in essence should one day be portable to any OS. for now I would just like to be able to compile it successfully)
PREFIX?=/usr/local
LDFLAGS= -L${PREFIX}/apr/lib -L .aprutil-1 -L .apr-1
CFLAGS=-g -Wall -pthread -I${PREFIX}/apr/include/apr-1 -I${PREFIX}/apr/include/apr-util-1
all: devpkg
devpkg: bstrlib.o db.o shell.o commands.o
install: all \
install -d $(DESTDIR)/$(PREFIX)/bin/ \
install devpkg $(DESTDIR)/$(PREFIX)/bin/
clean:
rm -f *.o \
rm -f devpkg \
rm -rf *.dSYM
I've gone and searched for it myself in the folders and this is what I got:
yotam#yotam-HP-ProBook-450://usr$ grep -r apr_pool_initialize .
./local/apr/include/apr-1/apr_pools.h:APR_DECLARE(apr_status_t) apr_pool_initialize(void);
Binary file ./local/apr/lib/libapr-1.so.0.4.6 matches
Binary file ./local/apr/lib/libapr-1.a matches
Binary file ./local/apr/lib/libapr-1.so.0.5.1 matches
Binary file ./local/apr/lib/libapr-1.so.0.4.5 matches
./local/apr/lib/apr.exp:apr_pool_initialize
After the reaserch I did, I clearly understand that this is a linker problem. but I wasn't able to find the command to do the trick.
Thanks in advance.
Looks like you're missing the link option that tells cc which library to link with. I'm not sure what .aprutil-1 and .apr-1 are in your LDFLAGS macro, since you specify them with -L, I will assume they are directories.
However, if you change your line to add the -l option to specify the library, it should get you closer.
EDIT: Because the linker is a single pass tool, all the libraries need to be listed after the objects, so the symbols will not be optimized away. LDLIBS is a typical name for the macro where libraries are specified, and you can tack them on to the end of the compile/link command and it should work.
LDFLAGS= -L${PREFIX}/apr/lib -L .aprutil-1 -L .apr-1
LDLIBS= -lapr-1 -laprutil-1
The last two args tell the linker which library names (prepended with lib and appended with .a) to use. The -L option specifies additional directories to search for libraries, it doesn't actually include anything.
Alternatively, you can also set LD_LIBRARY_PATH to point to your library directories.
You can consult this site (among others) as a reference, if you need more help debugging.
Try replacing LDFLAGS with LDLIBS, as in:
LDLIBS=-L${PREFIX}/apr/lib -lapr-1 -pthread -laprutil-1
instead of:
LDFLAGS=-L${PREFIX}/apr/lib -lapr-1 -pthread -laprutil-1
This is because the LDFLAGS variable is meant for non-library options for the linker, whereas in this case you are using libraries.
Iam trying to compile the code example available on the libmosquitto website (at the bottom):
http://mosquitto.org/man/libmosquitto-3.html
Iam using Ubuntu 12.04 and I've installed libmosquitto1 and libmosquitto1-dev packages. Before installing them I added the mosquitto repository:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
Iam trying to compile the example as follows:
gcc -lmosquitto mosquito.c -o mosquito
But I get the following errors:
/tmp/cc6eU8kw.o: In function `my_connect_callback':
mosquito.c:(.text+0xf8): undefined reference to `mosquitto_subscribe'
/tmp/cc6eU8kw.o: In function `main':
mosquito.c:(.text+0x298): undefined reference to `mosquitto_lib_init'
mosquito.c:(.text+0x2b4): undefined reference to `mosquitto_new'
mosquito.c:(.text+0x310): undefined reference to `mosquitto_log_callback_set'
mosquito.c:(.text+0x324): undefined reference to `mosquitto_connect_callback_set'
mosquito.c:(.text+0x338): undefined reference to `mosquitto_message_callback_set'
mosquito.c:(.text+0x34c): undefined reference to `mosquitto_subscribe_callback_set'
mosquito.c:(.text+0x364): undefined reference to `mosquitto_connect'
mosquito.c:(.text+0x3b4): undefined reference to `mosquitto_loop'
mosquito.c:(.text+0x3c8): undefined reference to `mosquitto_destroy'
mosquito.c:(.text+0x3d0): undefined reference to `mosquitto_lib_cleanup'
collect2: ld returned 1 exit status
Can someone give me some tips on how to compile this simple example?
Thanks
You have to put the -lmosquitto at the end (after the source files).
gcc mosquito.c -lmosquitto -o mosquito
# or
gcc mosquito.c -o mosquito -lmosquitto
# or
gcc -o mosquito mosquito.c -lmosquitto
Or better:
gcc -Wall -Wextra -pedantic -o mosquito mosquito.c -lmosquitto
I've installed the following two msi on my Windows 7 (basic) 64-bit — I downloaded the msi from here.
gstreamer-sdk-devel-x86_64-2013.6.msi
gstreamer-sdk-x86_64-2013.6.msi
Now I'm trying to build this hello world program using MinGW (GCC 4.8.1) and the linker is giving me trouble, saying this:
C:\Users\Apelles\AppData\Local\Temp\ccwLMXuu.o: In function `gst_message_unref':
C:/gstreamer-sdk/0.10/x86_64/include/gstreamer-0.10/gst/gstmessage.h:347: undefined reference to `gst_mini_object_unref'
C:\Users\Apelles\AppData\Local\Temp\ccwLMXuu.o: In function `main':
F:\projects\gstreamer/helloworld.c:9: undefined reference to `gst_init'
F:\projects\gstreamer/helloworld.c:12: undefined reference to `gst_parse_launch'
F:\projects\gstreamer/helloworld.c:15: undefined reference to `gst_element_set_state'
F:\projects\gstreamer/helloworld.c:18: undefined reference to `gst_element_get_bus'
F:\projects\gstreamer/helloworld.c:19: undefined reference to `gst_bus_timed_pop_filtered'
F:\projects\gstreamer/helloworld.c:24: undefined reference to `gst_object_unref'
F:\projects\gstreamer/helloworld.c:25: undefined reference to `gst_element_set_state'
F:\projects\gstreamer/helloworld.c:26: undefined reference to `gst_object_unref'
collect2.exe: error: ld returned 1 exit status
Which lib(s) am I missing?
Here are options which I used to build the project (taken from my make output):
gcc helloworld.c -ggdb -Wall -Wextra -ansi -std=c99 -Wno-unused-parameter -mms-bitfields -IC:/gstreamer-sdk/0.10/x86_64/include/gtk-2.0 -IC:/gstreamer-sdk/0.10/x86_64/lib/gtk-2.0/include -IC:/gstreamer-sdk/0.10/x86_64/include/atk-1.0 -IC:/gstreamer-sdk/0.10/x86_64/include/cairo -IC:/gstreamer-sdk/0.10/x86_64/include/gdk-pixbuf-2.0 -IC:/gstreamer-sdk/0.10/x86_64/include/pango-1.0 -IC:/gstreamer-sdk/0.10/x86_64/include/glib-2.0 -IC:/gstreamer-sdk/0.10/x86_64/lib/glib-2.0/include -IC:/gstreamer-sdk/0.10/x86_64/include/pixman-1 -IC:/gstreamer-sdk/0.10/x86_64/include/fontconfig -IC:/gstreamer-sdk/0.10/x86_64/include/freetype2 -IC:/gstreamer-sdk/0.10/x86_64/include -IC:/gstreamer-sdk/0.10/x86_64/include/libpng15 -mms-bitfields -IC:/gstreamer-sdk/0.10/x86_64/include/gstreamer-0.10 -IC:/gstreamer-sdk/0.10/x86_64/include/glib-2.0 -IC:/gstreamer-sdk/0.10/x86_64/lib/glib-2.0/include -IC:/gstreamer-sdk/0.10/x86_64/include/libxml2 -LC:/gstreamer-sdk/0.10/x86_64/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -lintl -LC:/gstreamer-sdk/0.10/x86_64/lib -lgstinterfaces-0.10 -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lxml2 -lglib-2.0 -lintl
What is lacking in this?
What should I do in order to resolve this?
I suspect your are using MinGW's default GCC compiler which targets the x86 architecture but you have downloaded the x86_64 version of the SDK. The linker can find the libraries but I won't be able to use them.
We strongly recommend to use cerbero's build system to setup the development environment. It will take care of downloading a working toolchain and compile all the build dependencies (autotools, gettext, libtoo, pkg-config, etc...)
You will find detailed instructions here in the section Build a single project with the SDK
In short:
checkout cerbero's repo
run the bootstrap command with: ./cerbero-uninstalled -c config/win64.cbc bootstrap
enter the development shell with: ./cerbero-uninstalled -c config/win64.cbc shell