The SDL-2 library I'm using was compiled from source.
Whenever I try to run any program that uses SDL-2 on X11, I am given this error:
SDL_Init Error: No available video device
I am running these programs through the command line on Linux Mint 19.3 Tricia.
Here's the ./configure summary:
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math : mmx 3dnow sse sse2 sse3
Audio drivers : disk dummy oss
Video drivers : dummy opengl_es2 vulkan
Input drivers : linuxev linuxkd
Using libsamplerate : NO
Using libudev : NO
Using dbus : NO
Using ime : YES
Using ibus : NO
Using fcitx : NO
Looks like your SDL build is missing the X11 backend.
Mint looks sufficiently Debian-y that a sudo apt build-dep libsdl2 ought to pull in the required -dev packages. Then you can re-run ./configure & rebuild/reinstall SDL.
Make sure to double-check that the Video drivers line in the configure summary has the backends you're interested in using.
If the build-dep method is too hand-wavy then docs/README-linux.md has a (kinda old) itemized -dev package list:
================================================================================
Build Dependencies
================================================================================
Ubuntu 13.04, all available features enabled:
sudo apt-get install build-essential mercurial make cmake autoconf automake \
libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \
libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \
libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \
fcitx-libs-dev libsamplerate0-dev libsndio-dev
Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
to that command line for Wayland support.
NOTES:
- This includes all the audio targets except arts, because Ubuntu pulled the
artsc0-dev package, but in theory SDL still supports it.
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
for higher-quality audio resampling. SDL will work without it if the library
is missing, so it's safe to build in support even if the end user doesn't
have this library installed.
- DirectFB isn't included because the configure script (currently) fails to find
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
configure script to include DirectFB support. Send patches. :)
Related
I'm running Ubuntu 20.04 and trying to use the SDL2 library to build a C++ program. I've installed the library from apt, so didn't compile it myself. I'm also using CMAKE.
The problem is that I can't run the program because it reports an error saying:
Could not create window: No available video device
I've read this and this and much more links, but none worked. I already installed:
xorg-dev
libx11-dev
libgl1-mesa-glx
libsdl2-dev
(with sudo apt install xorg-dev libx11-dev libgl1-mesa-glx libsdl2-dev.)
If your DISPLAY environment variable is not set, you can either set it inline along with your app command
DISPLAY=:0.0 ./yourApp
or set it permanently in the console where you execute your app:
export DISPLAY=:0.0
./yourApp
To set environmental variables from CMake, you can use cmake set command set(ENV{DISPLAY} :0.0)
I've been following an OpenCV tutorial from a book. Prior to it, I have OpenCV already installed on my machine. I'm working with OpenCV & C++ on a terminal and compile my program with CMake. Here's my Ubuntu OpenCV version :
Ubuntu 18.04.4 LTS
OpenCV version : 4.2.0
The result in the book is different than mine, apparently they're using QT. And later on the next few chapters, they still use Qt. So, I went on to install Qt using these following codes :
sudo apt-get install qtcreator
sudo apt-get install qt5-default
I also followed installation docs from Qt Wiki. When I checked my Qt version, this is what I got :
$ qmake --version
QMake version 3.1
Using Qt version 5.9.5 in /usr/lib/x86_64-linux-gnu
So, now I have Qt installed in my machine, but how do I integrate this with my OpenCV so I can use it on my programs other than putting highgui lib ? I encountered this error :
The library is compiled without QT support in function
I've been looking around online but still don't know how to integrate it properly.
WHAT I'VE TRIED
Apparently there was no other way beside completely uninstall OpenCV and then compile & reinstalling it with QT on. This is what I do :
Uninstall OpenCV entirely, and reinstalled it again (did it 3x times already) by cloning OpenCV and OpenCV contrib from Github, and during building OpenCV with CMake in terminal, I've added WITH_QT = ON. here's the full set up that I used :
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
No issue and I got OpenCV installed correctly (tested with several programs). And here's the version :
$ pkg-config --modversion opencv
4.2.0
I also came across this question : OpenCV integration With Qt, but still no solution there. But why does I still get error on any project with QT on it (I have QT_RADIOBOX and other on createButton) even after I entirely reinstall, build and make OpenCV using WITH_QT=ON ? Does CMake failed to locate QT ?
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0-dev) /home/raisa/opencv_build/opencv/modules/highgui/src/window.cpp:597:
error: (-213:The function/feature is not implemented)
The library is compiled without QT support in function 'createButton'
[2] 10467 abort (core dumped) ./exerc13
Here's createButton :
//Create buttons
createButton("Blur", blurCallback, NULL, QT_CHECKBOX, 0);
createButton("Grey", greyCallback, NULL, QT_RADIOBOX, 0);
createButton("RGB", bgrCallback, NULL, QT_RADIOBOX, 1);
createButton("Sobel", sobelCallback, NULL, QT_PUSH_BUTTON, 0);
Any advice ?
UPDATE
I read about explicit path definition for Qt integration instead of just putting "WITH_QT=ON". So I decided to go with cmake-gui and defined each path for Qt path configuration. Like this :
WITH_QT=ON (checked in cmake-gui)
Qt5Concurrent_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5Concurrent
Qt5Core_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5Core
Qt5Gui_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5Gui
Qt5OpenGL_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5OpenGL
Qt5Test_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5Test
Qt5Widgets_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5Widgets
Qt5_DIR = /home/raisa/Qt5.9.9/5.9.9/gcc_64/lib/cmake/Qt5
(Qt installation folowing installation docs from Qt Wiki)
Again, OpenCV was installed perfectly. Tested by running simple programs. But still encounter the same error for Qt. I also can't make OpenGL work with OpenCV. Advice ?
Took me almost 2 weeks tried to integrate QT and OpenGL. I changed my CMake settings back & forth so I'm not exactly sure if this will be the same case for everyone but this this what worked for me. Make sure you have Java installed and configured correctly in your environment.
I have Java installed (checked with running java & javac), but somehow CMake couldn't find it in configuration, so I figured I did clean uninstall Java and reinstall it. I'd like to start with clean env. so I purge everything beforehand (Java, QT, OpenCV, OpenGL) and configure CMake again with QT and OpenGL, and it worked perfectly.
Clean uninstall OpenCV. Use uninstall if you configure OpenCV with CMake or simply do it with purge.
sudo apt-get purge '*opencv*'
sudo find / -name "*opencv*" -exec rm -rf {} \;
Download the latest OpenCV from official OpenCV website (now it's version 4.2.0).
Purge any QT and OpenGL and reinstall them again. Here's a very nice List of all Qt5 developement packages, available on Ubuntu, so you know what you need to install.
If you have Java installed, clean uninstall everything first. Here's a very nice post of how to do it, I'll put it here. (There will be many purge & remove in this part, make sure you read and understand what you're removing) :
Remove all the Java related packages (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ):
dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove
sudo apt-get -y autoremove
Purge config files (careful. This command removed libsgutils2-2 and virtualbox config files):
dpkg -l | grep ^rc | awk '{print($2)}' | xargs sudo apt-get -y purge
Remove Java config and cache directory:
sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf
Remove manually installed JVMs:
sudo rm -rf /usr/lib/jvm/*
Remove Java entries, if there is still any, from the alternatives:
for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done
Search for possible remaining Java directories:
sudo updatedb
sudo locate -b '\pack200'
If the command above produces any output like /path/to/jre1.6.0_34/bin/pack200 remove the directory that is parent of bin, like this: sudo rm -rf /path/to/jre1.6.0_34.
Reinstall Java, I'm using one from Oracle (now it's version 14). Download the file and install with sudo dpkg -i.
Install Apache Ant from Ubuntu Software Center.
Create file in etc/profile.d.
sudo nano /etc/profile.d/(yourjdkversion).sh
and put this lines (check your jdk version correctly before put it here)
export JAVA_HOME="/usr/lib/jvm/jdk-14"
export PATH="$PATH:${JAVA_HOME}/bin"
(I rebooted after this step).
Run java -version and ant-version, if return correct values then they're configured properly and you're ready. Mine :
java -version
java version "14" 2020-03-17
Java(TM) SE Runtime Environment (build 14+36-1461)
Java HotSpot(TM) 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
ant -version
Apache Ant(TM) version 1.10.7 compiled on September 1 2019
Install cmake-gui. Open it, put OpenCV source and build directory.
Configure
Search for option WITH_QT, WITH_OPENGL, and BUILD_JAVA, then tick all of them. NO NEED TO CHANGE ANY PATH, CMake will find it if it's there. Configure again.
Here's my latest setting after the configuration for reference, notice that CMAKE found QT, OpenGL (in GUI) and JAVA (last lines) properly. Full configuration for reference is here (gist). Java used to be in unavailable section, but CMake found it properly now. If your configuration's missing one of them, try to install what's missing. Mine :
OpenCV modules:
To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo python2 python3 stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: js ( --> Java used to be here, "unavailable" even though it's installed.)
Applications: tests perf_tests examples apps
Documentation: NO
Non-free algorithms: YES
GUI:
QT: YES (ver 5.9.5)
QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
GTK+: NO
OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
VTK support: YES (ver 6.3.0)
Java:
ant: /snap/bin/ant (ver 1.10.7)
JNI: /usr/lib/jvm/jdk-14/include /usr/lib/jvm/jdk-14/include/linux /usr/lib/jvm/jdk-14/include
Java wrappers: YES
Java tests: YES
Install to: /usr/local
If you make any changes make sure to configure again.
Generate.
Navigate to your build directory and install OpenCV as usual.
make -j8 (check how many threads you can support, I use -j8)
make install
DONE.
Run one or two OpenCV program with QT and OpenGL and see if it works.
To give as much background as possible -
I have a machine learning model trained using keras i'm trying to embed on an nvidia jetson tx2.
I have set up tensorflow on there (a bit of a pain in itself) however when i run my script i'm hitting an error with protobuf.
Using TensorFlow backend.
[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.1.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "external/protobuf/src/google/protobuf/any.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): This program requires version 3.1.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "external/protobuf/src/google/protobuf/any.pb.cc".)
Aborted (core dumped)
So - i upgraded protobuf using pip at first but i thought the clash is because c++ version is taking priority and the version in linux was still stating 2.6.1 however after building in c++ the version is now shown as 3.1.0 however i am still getting the same error.
From the nvidia dev forums i received some feedback
"/usr/lib/aarch64-linux-gnu/libprotobuf.so.9.0.1
This means that C/C++ code will find version 2.6.
pip install protobuf-3.1.0-py2.py3-none-any.whl
This means that Python code will find version 3.1.
You need to upgrade the C++ (system) library to match version 3.1.
I don't think there's a default package on Ubuntu that does this, so you will have to either hack it by building your own and installing it on top of the system package, or you will have to find a deb package that has a newer version that will still install on your current system."
Ive really been struggling with this as i cant find a way to upgrade the system files. Any help would be much appreciated
Thanks
edit: i'm also wondering could this be a clash with GTK (i am also using openCV here so thats worth a mention!)
Please check your version of libprotobuf-dev.
Please try to uninstall your existing one on your PC with following commands:
apt-get remove --purge libprotobuf-dev
Then, build new version of libprotobuf-dev:
apt-get install autoconf automake libtool curl make g++ unzip
wget https://github.com/google/protobuf/releases/download/v3.5.0/protobuf-cpp-3.5.0.tar.gz
tar -xvf protobuf-cpp-3.5.0.tar.gz
cd protobuf-3.5.0
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig
Good luck.
References:
https://github.com/BVLC/caffe/issues/5711
https://github.com/google/protobuf/issues/2979
step 1:
first, uninstall with purge protobuf
sudo apt-get remove --purge libprotobuf
step 2:
start a fresh one
$ wget https://raw.githubusercontent.com/jkjungavt/jetson_nano/master/install_protobuf-3.6.1.sh
sudo chmod +x install_protobuf-3.6.1.sh
./install_protobuf-3.6.1.sh #this time will take 30 min on my board.
I have been trying to install GLFW and GLFW3, using Terminal to install
sudo apt-get install GLFW
sudo apt-get install GLFW3
Whenever I do so, I get results such as
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package glfw3
I have been trying to install GLFW for two hours now, and I'm getting a bit impatient. Also I'm very new to Linux (Mint), so I apologize if I'm doing something stupid...
EDIT:
No matter what I try, my program encounters
/home/myusername/Desktop/basic_window.cpp:11:21: fatal error: GL/glfw.h: No such file or directory
#include <GL/glfw.h>
^
compilation terminated.
Having a frustrating time with this, not sure why this is much more complicated than the other libraries I've installed so far.
I have been trying to install GLFW and GLFW3, using Terminal to install...
On Mint 17, it looks like you need to install libglfw2. So perform a sudo apt-get install libglfw2.
If you plan on developing against it, then install libglfw-dev instead. Notice the lack of a version number.
If interested, perform apt-cache search glfw
In Debian-based systems such as Ubuntu and Mint, library packages typically have names that begin with "lib", and development headers (for compiling new programs that use the library) are in a separate package whose name ends with "-dev".
Ubuntu 14.04 has GLFW 2 packaged as libglfw2 and libglfw-dev. Mint doesn't seem to have those packages, but you can probably use the Ubuntu ones since Mint 17 is based on Ubuntu 14.04.
GLFW 3 isn't in Ubuntu 14.04, but it looks like it'll be in 14.10 (as libglfw3 and libglfw3-dev).
Unless you really need GLFW 3 specifically, you're probably better off sticking with the packaged GLFW 2. Packages get easy automatic upgrades; compiling stuff "by hand" is a good way to end up with lots of cruft in your system with no automatic upgrade or uninstall.
Download GLFW source packages from their website.
Extract the folder glfw-3.0.4 from the tarball
Open console
Navigate to the folder you just extracted and go inside of it using cd
Type cmake . (be sure you include the dot)
If cmake . fails, then type the following as root:
apt-get install cmake
If you don't think you're root then type the following:
sudo apt-get install cmake
If that doesn't work then type the following as root, or add sudo if you're not root:
apt-get install build-essential cmake
Once you have cmake installed, navigate back to the folder and try cmake . again.
I am new to doing manually installing.
I reinstalled sdl manually, now everytime I run pygame or a game that uses SDL (eg. solarwolf or supertux) I get the message: Unsupported console hardware.
I know my computer can run SDL, because it worked prior to the reinstallation.
I want to now how I can reinstall SDL properly, so that pygame will work again.
versions:
ubuntu: Ubuntu 10.04 LTS Lucid Lynx
sdl: 1.2.14
Stuff I have tried:
1)
I have tried this commandoes I found on the net:
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure --prefix=$HOME
make
make install
2)
I tried again with sudo and no prefix. Maybe that wrecked some prior configurationsfile or something?
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure
make
sudo make install
3)I used the Synaptic Package Manager to completely remove and reinstall all files starting with libsdl.
4)I have tried reinstalling supertux and solarwolf (with ubuntu software senter)
hoping it could resolve the problem if there were some missing dependencies.
Conclusion. I geuss a have installed sdl, but wrecked a confirgurationfile or something preventing communication between sdl and the graphic driver.
But that is a wild guess.
This sounds strange.
try: sudo ldconfig
from man ldconfig
"ldconfig creates, updates, and removes the necessary links and cache
(for use by the run-time linker, ld.so) to the most recent shared
libraries found in the directories specified on the command line, in
the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and
/lib). ldconfig checks the header and file names of the libraries it
encounters when determining which versions should have their links
updated. ldconfig ignores symbolic links when scanning for libraries.
"