"make" and library

This is a discussion on "make" and library within the C++ Programming forums, part of the General Programming Boards category; My current c++ application is compiled by calling "make", and invoked by calling "./fileName.bin". Now, I want to add the ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    43

    "make" and library

    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:
    Code:
    #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

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    43
    This is the content of my Makefile:
    Code:
     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

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C problem - Create a Personal Library
    By Harliqueen in forum C Programming
    Replies: 33
    Last Post: 04-21-2010, 12:27 AM
  2. how to create an Import Library in Vs2008
    By khumayun in forum C++ Programming
    Replies: 2
    Last Post: 03-19-2010, 11:49 AM
  3. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 07:04 AM
  4. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 05:52 AM
  5. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 08:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21