[cairo] [External] Installation

Helde, Paavo Paavo.Helde at revvity.com
Tue Dec 5 17:42:31 UTC 2023


This is not a cairo specific issue.

A general guide for solving 'undefined reference' errors in Linux/Unix:


  1.  Figure out which library (.a or .so) provides the missing functions. E.g:

> nm thirdparty/cairo/lib/libcairo.a | grep -w 'cairo_image_surface_create'
                 U cairo_image_surface_create
                 U cairo_image_surface_create
0000000000000da0 T cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create
                 U cairo_image_surface_create

The line with T indicates that 'cairo_image_surface_create' is indeed defined by this library.


  1.  Ensure that the directory of this file is passed to the compiler/linker command line via -L
  2.  Ensure that the name of this file without prefix and suffix is passed to the compiler/linker command line via -l, e.g. -lcairo in this case.
  3.  If still failing, move -lcairo to the end of the command line, the linking order is important.

That's it. Also suggesting to switch over to CMake, writing makefiles by hand feels more like writing PostScript by hand.

HTH
Paavo

From: cairo <cairo-bounces at cairographics.org> On Behalf Of Byron Blue
Sent: teisipäev, 5. detsember 2023 18:34
To: cairo at cairographics.org
Subject: [External] [cairo] Installation

You don't often get email from byronblue at hotmail.com<mailto:byronblue at hotmail.com>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
I've been trying (for quite a number of days) to get a simple addition of my code to compile under NetBSD 9.1 using a few Cairo graphics functions. I know my makefile must be missing something obvious. The installation instructions are poor at best. Here is the complaints from my compiler (gcc):
ld: /home/byron/working/unix/utilityModules.c:3280: undefined reference to `cairo_create'
ld: /home/byron/working/unix/utilityModules.c:3305: undefined reference to `cairo_image_surface_create'
ld: /home/byron/working/unix/utilityModules.c:3306: undefined reference to `cairo_create'
ld: /home/byron/working/unix/utilityModules.c:3307: undefined reference to `cairo_set_source_rgba'
ld: /home/byron/working/unix/utilityModules.c:3308: undefined reference to `cairo_rectangle'
ld: /home/byron/working/unix/utilityModules.c:3309: undefined reference to `cairo_fill'
ld: /home/byron/working/unix/utilityModules.c:3311: undefined reference to `cairo_set_source_rgba'
ld: /home/byron/working/unix/utilityModules.c:3312: undefined reference to `cairo_rectangle'
ld: /home/byron/working/unix/utilityModules.c:3313: undefined reference to `cairo_fill'
ld: /home/byron/working/unix/utilityModules.c:3315: undefined reference to `cairo_destroy'
ld: /home/byron/working/unix/utilityModules.c:3316: undefined reference to `cairo_surface_destroy'
Thank you for any help,
Byron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20231205/86da7d18/attachment-0001.htm>


More information about the cairo mailing list