4 Replies - 583 Views - Last Post: 18 August 2010 - 04:03 AM Rate Topic: -----

#1 onako  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 10

"make" and library

Posted 18 August 2010 - 02:21 AM

My current c++ application is compiled by calling "make", and invoked by calling "./fileName.bin".
Now, I want to add the functionality of cairo library into the application. Note that the the program written specifically
for testing cairo (outside my application) is compiled by
"g++ -o fileX $(pkg-config --cflags --libs cairo) fileX.cpp"
and invoked by "./fileX".
Now, I dont know how to link cairo library to my application that is invoked by calling make.
I added the following into my application:
#include <cairo.h>
#include <cairo-pdf.h>
int myPDFdrawing() {
  cairo_surface_t *surface;
  cairo_t *cr;

  //
  

  //
  surface = cairo_pdf_surface_create("pics/mojFajl.pdf", 500, 648);
  cr = cairo_create(surface);

  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size (cr, 40.0);
  
  cairo_translate (cr, 0.0, 150.0);

  cairo_move_to(cr, 100.0, 500.0);
  cairo_show_text(cr, "Disziplin ist Macht.");
  
  cairo_move_to (cr, -100, -110.5);
  cairo_line_to (cr, -180, -130.5);
  cairo_set_line_width (cr, .05);
  cairo_stroke (cr);
  cairo_show_page(cr);

  cairo_surface_destroy(surface);
  cairo_destroy(cr);

  return 0;

}


I tried invoking "make $(pkg-config --cflags --libs cairo)", but this is not appropriate.
I would appreciate your help on this.
Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: "make" and library

#2 onako  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 10

Re: "make" and library

Posted 18 August 2010 - 02:37 AM

This is the content of my Makefile:
 STXXL_ROOT      ?= /home/laptop/stxxl-1.2.1
STXXL_CONFIG    ?= stxxl.mk
include $(STXXL_ROOT)/$(STXXL_CONFIG)

# use the variables from stxxl.mk
CXX              = $(STXXL_CXX)
CPPFLAGS        += $(STXXL_CPPFLAGS)

# add your own optimization, warning, debug, ... flags
# (these are *not* set in stxxl.mk)
CPPFLAGS        += -O3 -Wall -g -DFOO=BAR

# build your application
# (my_example.o is generated from my_example.cpp automatically)
fileA.bin: fileA.o
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) fileA.o -o $@ $(STXXL_LDLIBS)


I guess it should be adapted somehow?
Thanks
Was This Post Helpful? 0
  • +
  • -

#3 Galik  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 23-January 10

Re: "make" and library

Posted 18 August 2010 - 02:37 AM

Try adding these to your Makefile

CXXFLAGS = $(pkg-config --cflags cairo)
LDFLAGS = $(pkg-config --libs cairo)
Was This Post Helpful? 0
  • +
  • -

#4 onako  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-July 10

Re: "make" and library

Posted 18 August 2010 - 03:16 AM

Still...
In file included from fileA.cpp:3099:
fileJ.cpp:6:19: error: cairo.h: No such file or directory
fileJ.cpp:7:23: error: cairo-pdf.h: No such file or directory

Any other suggestions?
Was This Post Helpful? 0
  • +
  • -

#5 Galik  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 23-January 10

Re: "make" and library

Posted 18 August 2010 - 04:03 AM

You could try also adding this line:

CFLAGS = $(pkg-config --cflags cairo)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1