Thread: Linker error in small API (gcc)

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    Linker error in small API (gcc)

    Hi, i'm new inthis forum, and relatively new in gcc, well i got a problem compiling a project. The project was developed in two parts since one of them is almost independent (controls a printer on the RS232 port). Both parts works fine, but trying to get them in a single binary is getting me a headache. The printer part is all done, i've encapsulated all the functionality in 6 functions defined in "printer.h" and "printer.c" files. This is for reducing the code in the other part so we can just include the file and call the respectively functions. But the linker throws an error

    ./Obj/callback.o(.text+0xda0): In function `vdCBCommandButton':
    : undefined reference to `IF_OnClick'

    But, i don't know what is causing the error, the printer.c has all the includes, and those are in the directories passed to the compiler

    Anyone have an idea of what i'm doing wrong?

    Best Regards
    P.S.: Sorry for the bad english

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You need to compile all the .c files together, or if you've already compiled one file, link in the appropriate .o file that was created.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    If you still can't figure it out, post the relevant #includes and how you are calling gcc, eg:

    gcc -o exename file1.c file2.c
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Apr 2010
    Posts
    2
    Thanks for the answers, i've solved it with your suggestions. The compiler didn't pass all the objects to the linker, because some of them were in other folder (my bad)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  2. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  3. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  4. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM
  5. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM

Tags for this Thread