Compile SDL2_Mixer with libvorbis statically - sdl

I've been trying to build SDL2_Mixer with OGG support but even though libvorbis and libogg libraries are part of their sources: https://hg.libsdl.org/SDL_mixer/file/7e59d684b070/external it doesn't seem to add support for ogg at compile time.
Interestingly if I provide these flags to SDL2_Mixer configure: --enable-music-ogg=true --enable-music-ogg-shared=false.
I get no errors but the support is missing. If I omit all of the above and just keep: --disable-shared --enable-static
I get the following error from the configure:
checking vorbis/vorbisfile.h usability... no
checking vorbis/vorbisfile.h presence... no
checking for vorbis/vorbisfile.h... no
checking for ov_open_callbacks in -lvorbisfile -lvorbis -logg -lm... no
configure: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)
configure: WARNING: Ogg Vorbis support disabled
But it doesn't make much sense to me since SDL2_Mixer comes with those libraries on its own :(.
I could be passing some paths or anything wrong to it but I have no idea what.
This is the CMakeLists.txt I am using to compile the project.
I've also bumped into this:
http://forums.libsdl.org/viewtopic.php?p=20698
which sounds close to my issue, though using an older SDL_Mixer.
And I've also bumped into this thread: https://swarminglogic.com/article/2014_11_crosscompile2 and it feels odd he downloads ogg and vorbis sources separately if those are part of SDL2_Mixer anyway. In any case I've tried to build the libraries separately too but wasn't able to make SDL2_Mixer see them either.
I would be very grateful for any hints on how to resolve this as I seem to be stuck at this point for quite a while now.
Thank you very much :)

Ok, so it seems although SDL2_Mixer comes with ogg and vorbis libraries it just doesn't use them to compile even if set to static.
I myself wasn't able to force those libraries in but there is this new branch of SDL2 demo that adds ogg and vorbis libraries to the project: https://gitlab.com/zub2/SDLDemo/tree/addOggVorbis
This comment in the CmakeLists.txt is a nice summary on what's going on:
"SDL2_mixer needs to find libogg and libvorbis, and it's not using pkg-config"
so CFLAGS etc. have to be used unfortunately.

Related

xcb linking errors with premake (C++)

I can't seem to make my premake5.lua configuration to link against xcb.
I get undefined reference to "xcb_connect". So far I've tried (in premake5.lua):
libdirs {os.findlib("xcb")}
links {"xcb", "xcb-randr" }
Notice that os.findlib returns the same path for both xcb and xcb-randr.
I tried installing all sorts of packages, running pkg-config on both libs to see the required flags and also inspecting if the generated make file ones matched.
I don't know if it is related but I'm running Debian under wsl.
Maybe i'm missing something. Thanks for the help.

Can CMake require static libraries (e.g., ZLIB)?

It has been years since I worked in C++, and I've never used CMake before. I'm trying to compile a program called ngmlr, which uses CMake. It worked seamlessly on other systems I tried to build it on. This time around, CMake finds ZLIB (Found ZLIB: /usr/lib64/libz.so (found version "1.2.3")), as required by ngmlr, but the subsequent make fails with ld: cannot find -lz.
I think I know what's happening: CMake found the dynamic ZLIB library (libz.so), but the CMakeLists.txt file requires static (I found the following option in the file: option(STATIC "Build static binary" ON)). As far as I can tell, the static library (libz.a) is missing on this machine. It's not in the same /usr/lib64 directory as libz.so. locate is not available.
Questions:
Does that seem correct?
For education, assuming this is the problem, can you force CMake to look specifically for static ZLIB? e.g., since the developer required static, it would have been nice to immediately know the missing static library was the problem, rather than the embarrassingly long amount of time it took me to figure it out.
I've looked extensively for a clear answer to both, but didn't find anything conclusive (e.g., Force cmake to use static libraries).
UPDATE
I did confirm that the problem is that ld could not find the static library. Now I'm particularly interested to know if the developer can tell CMake to throw an error if the static libraries are not present, and save someone else.
cmake version 2.8.8
Yes
Generally speaking it is up to Find-module authors. Some modules have special "static" option, others do not. Particularly Zlib module has not. That's why cmake global variable is set in subdirectory src/CMakeLists.txt: SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a"). But it is invoked after find_package( ZLIB REQUIRED ) command. Looks like a bug.
Now I'm particularly interested to know if the developer can tell CMake to throw an error if the static libraries are not present, and save someone else.
REQUIRED means that error will be thrown if package was not found. In your case it should be thrown if you move SET(CMAKE_FIND_LIBRARY_SUFFIXES before find_package
Perhaps you can build your project if disable STATIC option
cmake -G"Unix Makefiles" _PATH_ -DSTATIC=OFF
I'm no cmake expert, but in case this helps anyone. I had found setting CMAKE_FIND_LIBRARY_SUFFIXES successfully loaded the static lib, but I only wanted this for finding ZLIB, so I saved the previous value, set CMAKE_FIND_LIBRARY_SUFFIXES and reset it like so:
set(_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES "static.lib")
find_package(ZLIB ${ZLIB_VERSION} REQUIRED MODULE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(_CMAKE_FIND_LIBRARY_SUFFIXES)
Your CMakeLists.txt probably has this somewhere:
find_library(ZLIB z)
You can replace it with:
find_library(ZLIB libz.a)

how to get libtorrent to see boost?

I am compiling libtorrent-rasterbar-0.16.16 with msys and mingw.
./configure runs fine, until it gets to the boost library check.
I have boost 1.51, and I set $BOOST_ROOT, but that did not work.
Checking for boost libraries:
checking for boostlib >= 1.36... expr: syntax error
configure: We could not detect the boost libraries (version 1.36 or higher). If
you have a staged boost library (still not installed) please specify $BOOST_ROOT
in your environment and do not give a PATH to --with-boost option. If you are
sure you have boost installed, then check your version number looking in <boost/
version.hpp>. See http://randspringer.de/boost for more documentation.
checking whether the Boost::System library is available... no
configure: error: Boost.System library not found. Try using --with-boost-system=
lib
I tried the --with-boost-system= option, and that did not work either. I also copied libboost_system-mgw47-mt-1_51.a to the same directory as libtorrent... but it did not work.
What am I missing?
I have boost 1.51, and I set $BOOST_ROOT, but that did not work
It is very likely that configure can’t find boost header files. What you need is both the library and the sources, and your best avenue is still setting BOOST_ROOT.
On a linux box you would be installing the boost-devel package, but for mingw you should download the boost sources directly and unpack them. Then please make sure you are running,
BOOST_ROOT=/path/to/boost_1_51 ./configure

Locating Boost Libraries in Ubuntu

I want to build an autotools project which is making use of the boost libraries program_options and iostreams. Therefor I install those libraries:
sudo aptitude install libboost-iostreams-dev libboost-program_options-dev
Now ./configure is fine and the progam compiles. However the linking fails:
/usr/bin/ld: cannot find -lboost_program_options-mt
/usr/bin/ld: cannot find -lboost_iostreams-mt
This is a well documented issue and can be fixed either by fixing the autotools stuff or by linking boost_program_options to boost_program_options-mt and so forth. I choose to do the latter since this is not my project. However I am failing to locate the libraries installed in Ubuntu:
locate *boost*
returns a list of documentation and package information and some boost libraries I am not looking for. locate *program_options* is empty. The library is not under /usr/lib or /lib ... Any ideas?
For me they are under /usr/lib64 in ubuntu 13.04. But I would use boost m4
to let autotool take care of these dependencies automatically. So by including boost m4 in your configure.in, you can specify which boost modules and versions you require. Morever it would also find the required paths for you.
sometimes its impossible, especially for smaller apps and custom projects,
for future, boost includes are in /usr/include/boost ,
of course it depends on system type and distribution

How to run C++ library with OpenCV on the other computer (linux)?

I wrote a small project using C++, OpenCV 2.2 and g++ in Ubuntu 11.04. I need to make a library (.so would be better), but I want it to run on the other computer, without OpenCV installed.
I've tried to build dynamic library using -shared and -fPIC flags for g++, and copied OpenCV .so libs to the working directory. Actually I need only core and feature2d, but actually it requested lot's of other libs, including highgui, which also has many dependencies.
I tried static linking, using -Wl,-Bstatic flags, but also unsuccessfully.
Did someone has the same problems? I would appreciate any kind of help.
It is possible to build OpenCV without dependencies from system libraries. To turn of all the dependencies for OpenCV 2.2 on Linux you can run cmake with following arguments:
cmake -DWITH_1394=OFF -DWITH_CUDA=OFF -DWITH_EIGEN2=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF -DWITH_GTK=OFF -DWITH_OPENEXR=OFF -DWITH_PVAPI=OFF -DWITH_QT=OFF -DWITH_TBB=OFF -DWITH_UNICAP=OFF -DWITH_V4L=OFF -DWITH_XINE=OFF -DUSE_IPP=OFF -DOPENCV_BUILD_3RDPARTY_LIBS=ON ..
But in this case you will not be able to use many of functions form highgui module:
video reading and writing
working with camera
all functions working with GUI (like imshow)