[cairo] Finding cairo_gl libraries with cmake
Carlos López González
genetita at gmail.com
Wed Dec 26 04:46:53 PST 2012
Hi!
I'm working on create a small application sample to use a cairo_gl surface
on a GtkWindow.
For my system configuration (OSX 10.7.5 with XCode 4.5.2) I'm using cmake.
First I did this:
1) Download latest release and build it with gl enabled
$ wget http://cairographics.org/releases/cairo-1.12.8.tar.xz
$ tar -xvf cairo-1.12.8.tar.xz
$ cd cairo-1.12.8
$ ./configure --prefix=/Users/carlos/Software/cairo/ --enable-gl=yes
$ make
$ make install
At configure time I checked that Opengl was enabled:
OpenGL: yes
I checked that the installed cairo libraries has cairo-gl.h header.
Then I created a CMakeLists.txt for the project (it consists in a single c
file)
with the following content:
project(cairo-sample)
cmake_minimum_required(VERSION 2.6)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
include_directories(${GTK2_INCLUDE_DIRS})
link_directories(${GTK2_LIBRARY_DIRS})
add_definitions(${GTK2_CFLAGS_OTHER})
# Here I add the cairo paths and libraries manually
set(CAIRO_INCLUDE_DIRS "/Users/carlos/Software/cairo/include/cairo")
set(CAIRO_LIBRARY_DIRS "/Users/carlos/Software/cairo/lib")
set(CAIRO_LIBRARIES cairo gl)
# Need to add the path BEFORE because it will override the default from GTK
include_directories(BEFORE ${CAIRO_INCLUDE_DIRS})
link_directories(${CAIRO_LIBRARY_DIRS})
add_executable(cairo-sample cairo_sample.c)
target_link_libraries(cairo-sample ${CAIRO_LIBRARIES} ${GTK2_LIBRARIES})
Then I run cmake-gui and configure to produce a XCode project with default
settings.
Then I open the produced project in XCode and it complains at link time:
Ld
/Users/carlos/Software/my-test-area/my-test-area/build/Debug/cairo-sample
normal x86_64
cd /Users/carlos/Software/my-test-area/my-test-area/src
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch x86_64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-L/Users/carlos/Software/my-test-area/my-test-area/build/Debug
-L/opt/local/lib/Debug -L/opt/local/lib
-L/Users/carlos/Software/cairo/lib/Debug -L/Users/carlos/Software/cairo/lib
-F/Users/carlos/Software/my-test-area/my-test-area/build/Debug -filelist
/Users/carlos/Software/my-test-area/my-test-area/build/cairo-sample.build/Debug/cairo-sample.build/Objects-normal/x86_64/cairo-sample.LinkFileList
-mmacosx-version-min=10.7 -Wl,-search_paths_first
-Wl,-headerpad_max_install_names -lcairo -lgl -lgtk-x11-2.0 -lgdk-x11-2.0
-latk-1.0 -lpangocairo-1.0 -lXext -lXrender -lXinerama -lXi -lXrandr
-lXcursor -lXcomposite -lXdamage -lgdk_pixbuf-2.0 -lpangoft2-1.0 -lgio-2.0
-lXfixes -lcairo -lX11 -lpango-1.0 -lm -lfreetype -lfontconfig
-lgobject-2.0 -lglib-2.0 -lintl -lgl -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
-lpangocairo-1.0 -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor
-lXcomposite -lXdamage -lgdk_pixbuf-2.0 -lpangoft2-1.0 -lgio-2.0 -lXfixes
-lX11 -lpango-1.0 -lm -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0
-lintl -o
/Users/carlos/Software/my-test-area/my-test-area/build/Debug/cairo-sample
ld: warning: directory not found for option '-L/opt/local/lib/Debug'
ld: warning: directory not found for option
'-L/Users/carlos/Software/cairo/lib/Debug'
Undefined symbols for architecture x86_64:
"_cairo_gl_context_destroy", referenced from:
_on_expose_event in cairo_sample.o
"_cairo_gl_surface_create_for_window", referenced from:
_on_expose_event in cairo_sample.o
"_cairo_gl_surface_swapbuffers", referenced from:
_on_expose_event in cairo_sample.o
"_cairo_glx_device_create", referenced from:
_cairo_sample_gl_context_create in cairo_sample.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I've tried to specify cairo-gl for CAIRO_LIBRARIES variable but it
complains telling me this:
ld: library not found for -lcairo-gl
All code can be found here:
https://github.com/genete/my-test-area.git
I would appreciate any help to allow XCode to find the installed cairo-gl
libraries.
Thanks!
--
Carlos
http://synfig.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20121226/2f73eac4/attachment.html>
More information about the cairo
mailing list