Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2 compilation error on Rocky 8 #105

Open
lukespowerconverters opened this issue Oct 25, 2024 · 4 comments
Open

SDL2 compilation error on Rocky 8 #105

lukespowerconverters opened this issue Oct 25, 2024 · 4 comments

Comments

@lukespowerconverters
Copy link

I am trying to compile this code on a Rocky 8 VM and have been following the Fedora instructions. When trying to install onvif-gui, I get this error when I try to run onvif-gui:
AttributeError: module 'avio' has no attribute 'Player'

I then tried to see if it would give me more information when compiling and building from the source code. libavio does not compile correctly and prints out this error:

  CMake Error at CMakeLists.txt:108 (target_link_libraries):
    Target "avio" links to:

      SDL2::SDL2

    but the target was not found.  Possible reasons include:

      * There is a typo in the target name.
      * A find_package call is missing for an IMPORTED target.
      * An ALIAS target is missing.

I had followed all of the install dependencies instructions, and SDL2 is installed on my VM and has the correct sdl2-config.cmake file. Is there something else I have to do to get this to compile for RHEL?

@sr99622
Copy link
Owner

sr99622 commented Oct 25, 2024

Thank you so much for your inquiry. I very much appreciate the detailed info, it helps quite a bit. I tried installing Rocky Linux 8 on a vm but was unable to make the configuration work. However, it seems from your description that you have been able to install the dependencies.

There is an environment variable that sets the install directory of SDL2 which is SDL2_INSTALL_DIR. You could try setting that prior to compilation and see if it works, I'd wager about 50/50 chances of success.

Update:

I went back and tried again, but was not able to configure the environment needed for onvif-gui to work. The major stumbling block is installing the ffmpeg development libraries, for which I wasn't able to find an installer. There were also some issues with compiling liblivemedia, so I ended up throwing in the towel. I went and double checked the Fedora instructions, which seem to still be working. This is unfortunate, but the application needs these complex dependencies which may not be available on all platforms. Thank you so much for your interest in the project.

@lukespowerconverters
Copy link
Author

lukespowerconverters commented Oct 29, 2024

I had been able to install ffmpeg-devel after installing epel before the rpmfusion packages using the following commands:

sudo dnf install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm

And after some more fiddling with the CMakeLists.txt in libavio, I got it to compile by changing SDL2::SDL2 to just SDL2 and specifying the path for the SDL2 include library in target_include_directories:

target_link_libraries(avio PRIVATE 
    FFmpeg::FFmpeg
    SDL2
)

target_include_directories(avio SYSTEM PUBLIC
    include
    ${SDL2_INCLUDE_DIRS}
)

After following the rest of the instructions, I found I also needed to install these two rpms to get the gui to run correctly:

xcb-util-cursor
xcb-util-cursor-devel

Just in case anyone wants to use a Rocky or RHEL system, these couple changes should make it function :)

@sr99622
Copy link
Owner

sr99622 commented Oct 30, 2024

Hello,

Thank you so much for the feedback. I am wondering how you were able to get libsdl2-devel installed. I tried it by compiling from source since there doesn't seem to be a dnf package. Even though SDL2 compiles and installs into /usr/local/lib64 and I added that directory to the path, I'm still getting this error message when I try to install ffmpeg-devel

(myenv) [stephen@localhost ~]$ sudo dnf install ffmpeg-devel
Last metadata expiration check: 12:59:10 ago on Tue 29 Oct 2024 09:31:16 PM EDT.
Error: 
 Problem: package ffmpeg-devel-4.2.10-1.el8.x86_64 from rpmfusion-free-updates requires libavdevice(x86-64) = 4.2.10-1.el8, but none of the providers can be installed
  - package ffmpeg-devel-4.2.10-1.el8.x86_64 from rpmfusion-free-updates requires libavdevice.so.58()(64bit), but none of the providers can be installed
  - conflicting requests
  - nothing provides libSDL2-2.0.so.0()(64bit) needed by libavdevice-4.2.10-1.el8.x86_64 from rpmfusion-free-updates
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

Best Regards,

Stephen

@sr99622
Copy link
Owner

sr99622 commented Nov 2, 2024

Continuing in this thread, the following commands were helpful. Please note that this is being done for Rocky Linux 8.

Install available libraries

sudo dnf install cmake git 
sudo dnf group install "Development Tools"

From the previous post (I was missing the /usr/bin/crb enable)

sudo dnf install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm
sudo /usr/bin/crb enable

This will install the ffmpeg development libraries, but it only includes the runtime SDL2, so you need to get the sdl2 source and compile it for the development includes

cd /tmp
wget https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.30.8.tar.gz
tar xzf release-2.30.8.tar.gz
cd SDL-release-2.30.8
mkdir build
cd build
cmake ..
sudo make install

The next hurdle was getting Python development libraries, which seem unavailable on this version of Linux, so compile from source

cd /tmp/
wget https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz
tar xzf Python-3.12.7.tgz
cd Python-3.12.7

sudo ./configure --prefix=/opt/python/3.12.7/ --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi
sudo make -j "$(nproc)"
sudo make altinstall

Then add the path

export PATH=$PATH:/opt/python/3.12.7/bin

and create a virtual environment

cd
python3.12 -m venv myenv
source myenv/bin/activate

You also need the libxml2-devel libraries

sudo dnf install libxml2-devel

To compile liblivemedia, it is necessary to edit the libonvif/liblivemedia/CMakeLists.txt file by appending the CMAKE_CXX_FLAGS. The -DNO_STD_LIB=1 is to get around the C++20 requirement

set(CMAKE_CXX_FLAGS "-DSOCKLEN_T=socklen_t -DNO_OPENSSL=1 -DNO_STD_LIB=1")

The compilation should now work

git clone --recursive https://github.com/sr99622/libonvif
cd libonvif
assets/scripts/compile

To get over the xcb issues, I ran the command

sudo yum install xcb-util*

I noticed while running this in a VM on proxmox that the broadcast discovery didn't seem to work, although I have had success with other VMs on the same server. Adding the camera using the manual add on the discover tab worked, but uncovered a bug. You need to change the name of the camera by right clicking on the list and typing in a new name to avoid a null ptr bug when restarting the app, oops. This will be fixed soon.

I was able to get the discovery working by disabling the firewall. I'm sure there's better way to do it, but opening the udp port 3702 was not working. I also noticed that it was necessary to change the Audio Driver on the Settings->General panel to dummy to get cameras with audio running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants