A20 7" tablet running linux w/ Cairo and keep encountering segmentation fault

BART FALZARANO <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
I have an A20 7" tablet that has Linux and Cairo loaded.  I wrote a small test program below and compiled and linked the program to an executable.  But any cairo c program I attempt to run results in a segmentation fault.
I've even tried the framebuffer code further below to have Cairo output to the Linux framebuffer but also results in a segmentation fault.  The segmentation faults occur at cairo_show_text (cr, "Hello, world"); and cairo_stroke (cr);


Both programs compile and link fine without errors.  Please let me know what I am doing wrong.  It is possible my environment is not setup correctly but any help would be appreciated.  

Best regards,
Bart

gcc -mcpu=cortex-a9 -I /usr/include/cairo/ -mfloat-abi=softfp -mfpu=neon -c cairo_fb_test4.c -o cairo_fb_test4.o
gcc -mcpu=cortex-a9 -L /usr/lib/python2.7/site-packages -lcairo -mfloat-abi=softfp -mfpu=neon -o cairotest4 cairo_fb_test4.o

#include <cairo.h>           
                                  
#include <cairo.h>

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface =
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        cairo_t *cr =
            cairo_create (surface);

        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
        cairo_set_font_size (cr, 32.0);
        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
        cairo_move_to (cr, 10.0, 50.0);
        cairo_show_text (cr, "Hello, world");

        cairo_destroy (cr);
        cairo_surface_write_to_png (surface, "hello.png");
        cairo_surface_destroy (surface);
        return 0;
}

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <cairo.h>

int main(){
	int fbfd = 0;
	struct fb_var_screeninfo vinfo;
	struct fb_fix_screeninfo finfo;
	long int screensize = 0;
	char* fbp = 0;
	cairo_t* cr;
	cairo_surface_t *surface;

	// open the frame buffer file for reading & writing
	fbfd = open ( "/dev/fb0", O_RDWR );
	if (!fbfd) {
		printf ("Error: can't open framebuffer device.\n");
		exit (1);
	}
	printf ("The framebuffer device was opened successfully\n");

	if (ioctl (fbfd, FBIOGET_FSCREENINFO, &finfo)) {
		printf ("Error reading fixed information\n");
		close (fbfd);
		exit (2);
	}

	if (ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
		printf ("Error reading variable information\n");
		close (fbfd);
		exit (3);
	}

	// print info about the buffer
	printf ("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);

	// calculates size
	screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

	// map the device to memory 
	fbp = (char*) mmap (0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

	if ((int)fbp == -1) {
		printf ("Error: failed to map framebuffer device to memory\n");
		close (fbfd);
		exit (4);
	}

	printf ("The framebuffer device was successfully mapped to memory\n");

	surface = cairo_image_surface_create_for_data (fbp, CAIRO_FORMAT_ARGB32, 
		vinfo.xres, vinfo.yres, finfo.line_length); 
	cr = cairo_create (surface);
	cairo_move_to (cr, 100, 100);
	cairo_line_to (cr, 300, 300);
	cairo_stroke (cr);
	
	munmap (fbp, screensize);
	close (fbfd);
	return 0;
}

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.