sr99622 / libonvif

Onvif library with GUI implementation and built in YOLOX
GNU Lesser General Public License v2.1
173 stars 44 forks source link

Ubuntu 22.04 LTS can't make source #58

Open mladenb opened 1 year ago

mladenb commented 1 year ago

Hi,

I can't build the source code on Ubuntu 22.04. Here's the log output:

$ git clone --recursive https://github.com/sr99622/libonvif.git
Cloning into 'libonvif'...
remote: Enumerating objects: 3116, done.
remote: Counting objects: 100% (202/202), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 3116 (delta 137), reused 137 (delta 77), pack-reused 2914
Receiving objects: 100% (3116/3116), 4.86 MiB | 2.99 MiB/s, done.
Resolving deltas: 100% (2060/2060), done.
Submodule 'libavio' (https://github.com/sr99622/libavio) registered for path 'libavio'
Submodule 'libonvif/pybind11' (https://github.com/pybind/pybind11) registered for path 'libonvif/pybind11'
Cloning into '/home/user2/Downloads/libonvif/libavio'...
remote: Enumerating objects: 1133, done.        
remote: Counting objects: 100% (640/640), done.        
remote: Compressing objects: 100% (404/404), done.        
remote: Total 1133 (delta 445), reused 404 (delta 221), pack-reused 493        
Receiving objects: 100% (1133/1133), 284.23 KiB | 1.16 MiB/s, done.
Resolving deltas: 100% (773/773), done.
Cloning into '/home/user2/Downloads/libonvif/libonvif/pybind11'...
remote: Enumerating objects: 26161, done.        
remote: Counting objects: 100% (81/81), done.        
remote: Compressing objects: 100% (51/51), done.        
remote: Total 26161 (delta 36), reused 49 (delta 22), pack-reused 26080        
Receiving objects: 100% (26161/26161), 10.01 MiB | 2.45 MiB/s, done.
Resolving deltas: 100% (18356/18356), done.
Submodule path 'libavio': checked out 'a0e97b3a65cad675b81e5bff18154f730f440300'
Submodule 'pybind11' (https://github.com/pybind/pybind11) registered for path 'libavio/pybind11'
Cloning into '/home/user2/Downloads/libonvif/libavio/pybind11'...
remote: Enumerating objects: 26161, done.        
remote: Counting objects: 100% (81/81), done.        
remote: Compressing objects: 100% (51/51), done.        
remote: Total 26161 (delta 36), reused 49 (delta 22), pack-reused 26080        
Receiving objects: 100% (26161/26161), 10.14 MiB | 1.21 MiB/s, done.
Resolving deltas: 100% (18356/18356), done.
Submodule path 'libavio/pybind11': checked out 'e53d58af6c0ade85fa6edce6a228ad2aeace55ee'
Submodule path 'libonvif/pybind11': checked out '3cc7e4258c15a6a19ba5e0b62a220b1a6196d4eb'
user2@user2-HP:~/Downloads$ cd libonvif/
user2@user2-HP:~/Downloads/libonvif$ mkdir build
user2@user2-HP:~/Downloads/libonvif$ cd build/
user2@user2-HP:~/Downloads/libonvif/build$ cmake ..
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
-- Could NOT find Python3 (missing: Intrepreter) (found version "3.10.6")
-- pybind11 v2.11.0 dev1
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.10.6", minimum required is "3.6") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Checking for modules 'libavcodec;libavfilter;libavformat;libavutil;libswscale;libswresample'
--   Found libavcodec, version 58.134.100
--   Found libavfilter, version 7.110.100
--   Found libavformat, version 58.76.100
--   Found libavutil, version 56.70.100
--   Found libswscale, version 5.9.100
--   Found libswresample, version 3.9.100
-- Found FFmpeg: /usr/include/x86_64-linux-gnu  
-- Found Python3: /usr/bin/python3.10 (found version "3.10.6") found components: Interpreter Development NumPy Development.Module Development.Embed 
-- pybind11 v2.11.0 dev1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user2/Downloads/libonvif/build
user2@user2-HP:~/Downloads/libonvif/build$ make
[  2%] Building C object libonvif/CMakeFiles/libonvif.dir/src/onvif.c.o
[  5%] Building C object libonvif/CMakeFiles/libonvif.dir/src/cencode.c.o
[  7%] Building C object libonvif/CMakeFiles/libonvif.dir/src/sha1.c.o
[ 10%] Building CXX object libonvif/CMakeFiles/libonvif.dir/src/onvifboss.cpp.o
[ 12%] Linking CXX shared library libonvif.so
[ 12%] Built target libonvif
[ 15%] Building CXX object libonvif/CMakeFiles/onvif.dir/src/onvif.cpp.o
[ 17%] Building C object libonvif/CMakeFiles/onvif.dir/src/onvif.c.o
[ 20%] Building C object libonvif/CMakeFiles/onvif.dir/src/cencode.c.o
[ 22%] Building C object libonvif/CMakeFiles/onvif.dir/src/sha1.c.o
[ 25%] Building CXX object libonvif/CMakeFiles/onvif.dir/src/onvifboss.cpp.o
[ 27%] Linking CXX shared module onvif.cpython-310-x86_64-linux-gnu.so
[ 27%] Built target onvif
[ 30%] Building CXX object onvif-util/CMakeFiles/onvif-util.dir/src/onvif-util.cpp.o
[ 32%] Linking CXX executable onvif-util
[ 32%] Built target onvif-util
[ 35%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Clock.cpp.o
[ 37%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Decoder.cpp.o
[ 40%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Display.cpp.o
[ 42%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Encoder.cpp.o
[ 45%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Exception.cpp.o
[ 47%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Filter.cpp.o
[ 50%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Frame.cpp.o
[ 52%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Packet.cpp.o
[ 55%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Pipe.cpp.o
[ 57%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Player.cpp.o
[ 60%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Reader.cpp.o
[ 62%] Building CXX object libavio/CMakeFiles/libavio.dir/src/Writer.cpp.o
[ 65%] Linking CXX shared library libavio.so
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libswresample.a(audio_convert.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libavio/CMakeFiles/libavio.dir/build.make:280: libavio/libavio.so.1] Error 1
make[1]: *** [CMakeFiles/Makefile2:250: libavio/CMakeFiles/libavio.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
sr99622 commented 1 year ago

It looks like the situation is that the FFMPEG development libraries on the machine are static, but libavio requires dynamic linking. Normally, Ubuntu will install both the static and dynamic FFMPEG development libraries when using apt install. It may be that you have a custom FFMPEG installation that has only the static files.

You can find the libraries in the /usr/lib/x86_64-linux-gnu directory. The libraries are libavcodec, libavfilter, libavformat, libavutil, libswscale and libswresample. In your case there will probably only be '.a' extension files, what the program is looking for are the '.so' extensions.

Re-installing the FFMPEG libraries is probably the best option, with a caveat.

If there is a custom installation of FFMPEG on the machine, simply running the apt install utility may overwrite the existing files. This might cause other programs to stop working, so you might want to preserve those existing '.a' libraries before attempting to re-install the FFMPEG development libraries, then copy the old '.a' files back.

Thank you for your patience, your feedback is greatly appreciated

mladenb commented 1 year ago

You're absolutely right. As soon as you mentioned static ffmpeg libraries, I immediately realized that I recently downloaded those static ffmpeg binaries to just test something with some media files. Thank you a lot for this explanation, really appreciated.

mladenb commented 1 year ago

actually, I have to correct myself here.. even after I removed ffmpeg entirely from my system and installed libav*-dev, I had to intervene a bit in order to get this built. Here are the changes I had to make. In the build/ folder:

Hope this helps.

sr99622 commented 1 year ago

cmake will cache values when it runs, and it may preserve settings that are not useful if the machine configuration has been changed. This can often lead to confusing results if cmake is run multiple times with configuration changes in between runs. It's a good idea to delete the build folder and start from scratch if you don't get the expected result after a configuration change.

In your case the .a file is likely a vestige from a previous cmake run made prior to installing the .so files. If the build folder is deleted and a fresh build folder is created to run cmake, you will probably get a clean build without having to go into the cmake internal files. The command 'sudo rm -R build' from the libonvif directory will remove the build folder entirely. For windows, use the command 'rmdir /q /s build'

mladenb commented 1 year ago

i thought that too, but when i did make uninstall or make clean/distclean, something, I also later removed the entire source folder and redownloaded git repo again, and the .a file was still there, weirdly enough.. anyway, like i said, after manually fixing those 3 files, i've managed to actually build everything, so it works now :) thank you :)