Compiling cvblob on OSX does not correctly locate OpenCV libs - macos

I'm having issues with CVBlob locating the OpenCV installation on OSX 10.6. I have patch for the osx install as described in an earlier message on the cvblob wiki. When I run make, the build process immediately complains that it cannot find cv.h or highgui.h and then subsequently fails to locate additional symbols and vars declared in those headers.
The cmake command I am using is :
cmake -DOpenCV_DIR=/usr/local/Cellar/opencv/2.3.1a/ .
I can see that cv.h is contained in the includes directory in that location. I also tried the following cmake command where I specify the location of the OpenCV Cmake info:
cmake -DOpenCV_DIR=/usr/local/share/OpenCV/ .
Neither seems to correctly tell the cvblob installation where OpenCV is located.
Please help!
SR

In later versions of cvBlob, openCV is automatically located. But version 0.10.4 and before expects the openCV directory to be located next to the cvblob directory. Specifically, version 0.10.4 seems to expect the opencv-2.4.9 directory to be next to cvblob. In this version of cvBlob, the -DOpenCV_DIR parameter seems to have no effect on OS X, and this was the only way I could get it working.

Are you working with Xcode?
If so, just add the OpenCV-path to your header search path in your Xcode project.

Related

Linking my CMAKE project with libpng in Windows

I'm working on a C++ project that requires libpng. So far I've worked on Linux and everything is smooth. I installed libpng, CMAKE picks it up and everything is alright. Now move to Windows.
Here I first installed zlib (required by libpng) and libpng. When I say install, I mean I downloaded the source files, and then built them and install them using msbuild.
I noticed that by doing so, I got new folders under c:\program files (x86):
c:\program files (x86)\zlib
c:\program files (x86)\libpng
Seemed all right to me. Now when I configure my project with CMAKE zlib is picked up:
-- Found ZLIB: C:/Program Files (x86)/zlib/lib/zlib.lib (found version "1.2.13")
but there's no way CMAKE finds the PNG library:
Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
Now I tried to have a look at the FindPNG and I noticed this line:
find_path(PNG_PNG_INCLUDE_DIR png.h PATH_SUFFIXES include/libpng)
Does this mean that CMAKE expects the file png.h to be in a directory ending in include/libpng? If so, then it will never find it because in my case png.h is placed in libpng/include. But this is also the "official" installation from the source code just downloaded from http://www.libpng.org/pub/png/libpng.html.
So now I am superconfused. How things are supposed to work in Windows? Should I "create" a folder structure with the correct files for every library so that CMAKE is happy? In a way I hoped things in Windows were similar to what happens in Linux: libraries go in a standard folder, they are detected by CMAKE.. everything is ok. But apparently this is not the case. So my question in general is: how do you ship a package like this to a Windows user so that he can builds it without having to go through all this?
Thanks so much
Fabrizio
This would be the right one to use:
find_package(PNG)
You can tell CMake to look in the location where you installed it by adding the libpng base install location to CMAKE_PREFIX_PATH. Without this, CMake doesn't know where you put it.
cmake "-DCMAKE_PREFIX_PATH=C:/Program Files (x86)/libpng" ...
Note that FindPNG first looks for zlib and will fail if zlib could not be found.

GLEW and GLFW on Mac OS X (standalone)

I built a project on XCode using glew and glfw. The CMake file was given to me by a tutorial, so I don't actually know how to make one of the cpp files build by itself. When I pasted the code into a new standalone file, I got the errors:
error: GL/glew.h: No such file or directory
error: glfw3.h: No such file or directory
I googled these errors, but most of the solutions were for Linux and did not work for my Mac. GLEW and GLFW are indeed installed on my system, since I was using them successfully in my XCode project. I just don't know how to set the correct paths when I am compiling a standalone cpp file at the command line using g++.
use -I at the command line to indicate which include paths the compiler should search

Library not found OpenCV

I'm on mac 10.7.5, using xcode 4.6.2 and working with the OpenCV 2.4.3 library. I went through the process of making the build directory with the cmake files in terminal and did the download.
I added the .dylib files in Xcode and changed the header path, changed C++ Library to libstdc++, but when I compiled I got this error :
ld: library not found for -lopencv_calib3d.2.4.3
clang: error: linker command failed with exit code 1
I have libopencv_calib3d.2.4.3.dylib added in the project so I have no idea what else it needs.Any ideas?
If your "make back-end" is Cmake you should stick to using it. Local config changes in Xcode can "secretly" be overwritten when the cmake is rerun (which for example happens after you make changes to it) creating weird build errors and forcing you to remember all the manual changes you made.
Your problem seems to be that the generated project doesn't seem to know where to look for opencv.
Assuming you installed opencv using macports you should add a line saying
link_directories(/opt/local/lib)
to your CMakeLists.txt. (if you installed it using brew, or compiled it manually just replace /opt/local/lib for /usr/local/lib or the path to your compiled libraries)
Also make sure to link against opencv_calib3d instead of opencv_calib3d.2.4.3 (unless you have a very particular reason for bypassing this, but that usually means that something else is weird in the setup :) )
Final pointer that you might already know of: As you are already using Cmake you should add the libraries to link against using TARGET_LINK_LIBRARIES(...) in Cmake rather than manually adding them in Xcode (referring to my previous argument).

issues with freeglut on mac os snow leopard (it builds fine via macports)

im on mac os snow leopard gcc 4.5.4 | gcc 4.2.1, trying to build the tutorials http://www.arcsynthesis.org/gltut/
one needs to build dir glsdk first. I install freeglut (prerequisite) via macports freeglut #2.8.0_1 (active) and manually copy and paste its lib and include folders in dir glsdk so that
ls ..../Tutorial_0_3_8/glsdk/freeglut -> include lib
(I couldn't build the freeglut provided that's why I replace it with the one from macports)
after fixing many errors (mostly due to legacy snippets included) I'm testing the build in Test dir and when I try to run the generated executable ./TestD, I get:
X Error of failed request: BadRequest (invalid request code or no such operation)
Major opcode of failed request: 34 (X_UngrabKey)
Serial number of failed request: 28
Current serial number in output stream: 28
what's this? a bit of search suggests this is a driver's problem(?)..
when I use glut with other gl code it runs just fine
my X11 is broken** and this seems to be the problem.
since it's tricky to build this set of tutorials, I repeat the steps I followed for anyone facing similar trouble
get the source https://bitbucket.org/alfonse/gltut/downloads, untar and fill in the gaps so that you have Tutorial_0_3_8 instead of Tutorial 0 3 8
in glsdk directory, comment out --"freeglut/freeglut.lua, in premake4.lua
in glsdk directory, ./premake gmake and then make config=release
in framework directory, framework.cpp, manually replace macros LOCAL_FILE_DIR & GLOBAL_FILE_DIR with "./data/" "./data/" & "../data/" respectively and comment out #include "directories.h"
build all the tutorials in a single step from root or those that you need, e.g. in Test directory put the right paths to include for freeglut headers and link with the:
in Test.make replace -I../glsdk/glutil/include and -L../glsdk/glutil/lib with paths from freeglut build via macports. Also in the same makefile link with -lglut instead of -lfreeglut
**dyld: Symbol not found: __cg_DGifGetLine
Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libGIF.dylib
in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO

How to setup Qt Creator to work with CMake on Mac with Qt 4.7 SDK?

I'm using Qt Creator 2.2.1 under MacOS X 10.6.8, standard MacOS X install for CMake 2.8.5 and Qt SDK version 1.1.2 released on June 21st (Qt 4.7.3 libraries).
My CMakeLists.txt fails in the find_package for Qt4 -- the second of the lines below:
set (CMAKE_MODULE_PATH /Applications/CMake 2.8-5.app/Contents/share/cmake-2.8/Modules)
find_package (Qt4 REQUIRED HINTS /Users/myname/QtSDK)
I added the first just to make sure it knew where FindQt4.cmake lives, but same error either with or without that line.
The error from CMake is as follows:
-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:30 (find_package):
Could not find a configuration file for package Qt4.
Set Qt4_DIR to the directory containing a CMake configuration file for Qt4.
The file will have one of the following names:
Qt4Config.cmake
qt4-config.cmake
I've done some finds in both the installed QtSDK location and the CMake directories, and there's no Qt4Config.cmake. I did see in the CMake module directory -- FindQt4.cmake, Qt4ConfigDependentSettings.cmake, and UseQt4.cmake
According to this page:
The find_package() command will look in the module path for Find.cmake,
which is the typical way for finding libraries. First CMake checks all directories in
${CMAKE_MODULE_PATH}, then it looks in its own module directory
/share/cmake-x.y/Modules/.
If no such file is found, it looks for Config.cmake or
-config.cmake, which are supposed to be installed by libraries
(but there are currently not yet many libraries which install them) and
that don't do detection, but rather just contain hardcoded values for the
installed library.
So it seems like FindQt4.cmake should find the Qt4 I'm hinting at its location -- so why is it even making it down to Qt4Config.cmake? Anyone get this to work on Mac with those standard installs?
The "find_package(Qt4..." command is very dependent on finding a qmake executable. Is "qmake" on your path? Try something like
set(QT_QMAKE_EXECUTABLE "<actual location of qmake on your system>")
find_package(Qt4 REQUIRED)
Edit: I meant to type QT_QMAKE_EXECUTABLE; and I did not grok your statement about CMAKE_MODULE_PATH at first.

Resources