Getting started with OpenCV on Macbook - macos

I installed openCV on snow leopard with homebrew. Any opencv program I try to run cannot find the required header files.
I understand that the paths of the header files has to be defined. I need help with how I do that?

Use pkg-config to make your job easier:
g++ test.cpp -o test `pkg-config --cflags --libs opencv`

Related

Mono mkbundle on OSX

I'm trying to create a standalone of my C# app using mono's mkbundle, I got Xcode installed and the Mono Developer Kit too (I'm sure it's MDK not the runtime). Yet I run mkbundle using
mkbundle test.exe
and I get these errors
Compiling:
as -o temp.o temp.s
cc -g -o a.out -Wall temp.c `pkg-config --cflags --libs mono-2` temp.o
sh: pkg-config: command not found
temp.c:1:10: fatal error: 'mono/metadata/mono-config.h' file not found
1 error generated.
[Fail]
What's happening?
pkg-config is stored at '/Library/Frameworks/Mono.framework/Commands'.
Solution (see here and here):
Prepend the "/Library/Frameworks/Mono.framework/Commands" folder to
your PATH variable:
export PATH=/Library/Frameworks/Mono.framework/Commands:$PATH
This is needed in addition to the architecture solution proposed by aiapatag and the objective-c runtime and CoreFoundation framework solution:
export AS="as -arch i386"
export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
It looks like the pkg-config tool is not found. Maybe it's not in the default paths.
Do you have a 'pkgconfig' directory somewhere? It should be a subdirectory of your Mono installation.
Try to see if you have a path looking like /Library/Frameworks/Mono.framework/Versions/XXXX/lib/pkgconfig
If yes, point the PKG_CONFIG_PATH environment variable to this path, you can specify it directly when running your mkbundle command (this is just an example):
$ PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/XXXX/lib/pkgconfig mkbundle ....

Static cross-compilation of GTK applications on Fedora for Windows?

I'm trying to build gtk3 applications for windows and since Fedora delivers mingw and precompiled libraries for gtk3 for mingw, I used it.
I got the normal compilation working via
i686-mingw32-gcc test.c `pkg-config --cflags --libs gtk+-win32-3.0`
Now I would like to link it statically (Fedora delivers precompiled libraries for that too) but i cannot get it to work. It tryed
i686-mingw32-gcc test.c -static `pkg-config --cflags --libs --static gtk+-win32-3.0`
but it results in
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgtk-3
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgdk-3
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lpng14
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lffi
AFAIK, static compilation is not supported for GTK+. Anyway, gcc arguments order is important for building with mingw.

GTK+ macport on os x

I currently installed gtk2 through macport on os x 10.6 but when i tried to use library like
#include <gtk/gtk.h>
it still doesn't recognize it and give me compile errors.
does anyone know how to install gtk2?
If you have pkg-config on your system, try:
pkg-config --cflags gtk+-2.0
MacPorts installs its header files and libraries in /opt/local/include and /opt/local/lib, respectively. Did you add -I/opt/local/include and -L/opt/local/lib to your compiler flags?

Makefile for a simple application

I have a file app.c which uses two libraries GStreamer and libXml2. To compile the application I type the following on Terminal
gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) app.c -o app -I/usr/include/libxml2 -lxml2
When I try to Makefile with the contents as follows :
all:
gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) app.c -o app -I/usr/include/libxml2 -lxml2
run:
./app
clean:
rm app
On running make command I get the errors as expected. What is the significance of
$(pkg-config --cflags --libs gstreamer-0.10)
on Echoing the above I get some files which when included in Makefile gives me the correct output.
pkg-config --cflags libraryX outputs the path to the header files of libraryX. Without this, the compiler does not know where to look for the header files, and compilation will fail.
Similarly, pkg-config --libs libraryX outputs the path to the actual compiled library files of libraryX. Without this, the linker does not know where to look for the library files, and linking will fail.
pkg-config --cflags --libs libraryX is just combining what I described above. Since you're using gcc to do both compilation and linking, you just pass those parameters together to gcc.

skipping incompatible library (lmono) while cross compiling c with mono

Ok for now i managed to call managed code (mono) from native C code
referring to:
http://www.mono-project.com/Embedding_Mono
which works on my host system (x86) ubuntu.
Now i try to crosscompile it for my target (arm) debian system.
Crosscompiler is arm-none-linux-gnueabi-gcc 2010 from Codesourcery
when i go for:
arm-none-linux-gnueabi-gcc 'pkg-config --cflags glib-2.0 --libs mono' -o main.o main.c
i get
Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lmono
so the libmono.so , libmono.a was found in /usr/lib and i go for:
arm-none-linux-gnueabi-gcc -L/usr/lib 'pkg-config --cflags glib-2.0 --libs mono' -o main.o main.c
which results in:
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libmono.so when searching for -lmono
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libmono.a when searching for -lmono
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lmono
somebody has advice?
best regards
Gobliins
Build libmono for ARM first, instead of trying to use your x86 build.

Resources