Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Linux makefile / glade2 / libtag / gcc linking problem.

Options
  • 31-03-2006 4:04pm
    #1
    Closed Accounts Posts: 7,230 ✭✭✭


    Hey there. I've used glade2 to create a gtk GUI, this in turn generated a whole load of source files, makefiles and the like. If you're familiar with glade or glade2 you'll know what I'm on about.

    Anyway, I'm adding to main.c (one of the generated source files). I'm including the taglib c bindings header file (#include <tag_c.h>), and attempting to call the functions contained therein, in main.c. If I create a seperate source file, not for use in this package, lets say test2.c, it is compiled and linked as follows:
    gcc -Wall  -I/usr/include/taglib -c test2.c
    gcc -o test2 test2.o /usr/lib/libtag_c.so
    

    So, what I want to do is get the Makefile to use -I/usr/include/taglib for main.c, and when linking to link against /usr/lib/libtag_c.so as shown above.

    I've edited the Makefile found in <packagename>/src and in <packagename> like so:
    PACKAGE_CFLAGS = <all of the generated gtk crap here> -I/usr/include/taglib
    
    and
    PACKAGE_LIBS = <all of the generated gtk crap here> -ltag_c
    

    But it doesn't seem to be compiling with those flags, as you can see from here:
    gcc -DHAVE_CONFIG_H -I. -I. -I.. 
    -DPACKAGE_DATA_DIR=\""/usr/local/share"\"     -DPACKAGE_LOCALE_DIR=\""/usr/local/share/locale"\"       
    -I/usr/include/gtk-2.0 
    -I/usr/lib/gtk-2.0/include 
    -I/usr/include/atk-1.0 
    -I/usr/include/cairo 
    -I/usr/include/pango-1.0 
    -I/usr/include/glib-2.0 
    -I/usr/lib/glib-2.0/include      
    -g -O2 -c main.c
    main.c:21:19: error: tag_c.h: No such file or directory
    main.c: In function 'scan_directory':
    main.c:62: error: 'TagLib_File' undeclared (first use in this function)
    main.c:62: error: (Each undeclared identifier is reported only once
    main.c:62: error: for each function it appears in.)
    main.c:62: error: 'file' undeclared (first use in this function)
    main.c:63: error: 'TagLib_Tag' undeclared (first use in this function)
    main.c:63: error: 'tag' undeclared (first use in this function)
    main.c:64: error: syntax error before '*' token
    main.c:73: warning: 'return' with a value, in function returning void
    main.c:82: error: 'properties' undeclared (first use in this function)
    main.c: In function 'file_select':
    main.c:93: warning: conflicting types for built-in function 'rindex'
    make[2]: *** [main.o] Error 1
    make[2]: Leaving directory `/home/sj/Projects/zenjb/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/sj/Projects/zenjb'
    make: *** [all-recursive-am] Error 2
    

    As you can see gcc is not using the libs I want to it to. I'm sure there is a simple solution and realise this is a pure newbie question, so please don't flame me. In conjunction with this post I am currently googling my heart out, but I'm on 56k and it's taking me ages, hence the post.

    Thanks for your time!


Comments

  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    Here's the contents of the Makefile from the mainpackage dir:
    http://www.rafb.net/paste/results/bzbkhd26.html

    and here's the contents of the makefile from the 'src' dir, where main.c is located.
    http://www.rafb.net/paste/results/GbC9HF71.html

    Sorry about having to use the paste-bin, but boards told me the contents of each makefile was too big to post on here. :o


  • Registered Users Posts: 441 ✭✭robfitz


    You could try adding PACKAGE_CFLAGS to COMPILE, and PACKAGE_LIBS to LIBS or LINK (link order might be an issue). Something like:

    COMPILE += PACKAGE_CFLAGS
    LIBS += PACKAGE_LIBS


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    Cheers rob, in the end I changed CFLAGS = -g -O2 to CFLAGS = -g -O2 -I/usr/include/taglib and I added LIBS = -ltag_c which seems to have worked perfectly, mind you it compiles every source file with those options, but that's fine for me for now.


  • Registered Users Posts: 441 ✭✭robfitz


    Using Target-specific Variable Values might also be an option.

    Something like this can be used to add to flags or add extra flags:

    main.o : CFLAGS+=-I/usr/include/taglib


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    robfitz wrote:
    Using Target-specific Variable Values might also be an option.

    Something like this can be used to add to flags or add extra flags:

    main.o : CFLAGS+=-I/usr/include/taglib

    That worked like a charm rob, way better than my quick-hack solution. Thanks a million :)


  • Advertisement
Advertisement