Linker Error

This is a discussion on Linker Error within the C Programming forums, part of the General Programming Boards category; I have a source code file that will compile - but will not link. Linker error gives issues "undefined symbol", ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    Linker Error

    I have a source code file that will compile - but will not link. Linker error gives issues "undefined symbol", etc.

    I have attached the files below...

    If anyone wants to see if I am missing anything. The files have compiled perfectly in the past - the issue is that I have inherited all of this and need to make a slight adjustment to some of the code - an onscreen visual change - nothing "computational"

    The system is old, the code is old, alas I know all this and as much as I wish it were not, it is what I have been left with.

    Any assistance would be a great help.
    Last edited by tcpurvis; 03-02-2011 at 01:27 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    How about posting some error messsages, or your compiler log?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    I looked at the mak file...why are you using Turbo C?!

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    5
    I have inherited this dog's breakfast. From looking at the mak file should I be using something else? I am using what it was developed with to run on the systems that are still in place. It is old (I have sad this before) - I am just trying to solve the problem - that's all.
    Last edited by tcpurvis; 03-02-2011 at 01:29 PM. Reason: amendment

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Timothy... please post your code *here*, using the appropriate code tags...

    Many people, myself included, are very reluctant to go to private websites and download unknown files...

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    In principle, each one of the .h files in your zip file has a companion .c file or a companion .lib file.

    Without either of these, you're pretty much stuck.

    You need to go back to whoever gave you the code to find out where the extra files are.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    Files included

    As mentioned above, here are the files if anyone is curious enough to look.

    Timothy
    Attached Files Attached Files
    Last edited by tcpurvis; 03-02-2011 at 01:30 PM.

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    2,510
    Quote Originally Posted by Salem View Post
    How about posting some error messsages, or your compiler log?
    If you are NOT willing to do the above; I see no reason to even try to help you.

    Tim S.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    @tcpurvis
    Do you know the difference between a .c file and a .h file?

    Header files are for the compiler only, to tell it about things which exist elsewhere.


    Code:
    // this is magic.h
    extern int magic;
    void spell();
    Code:
    // this is wizard.c
    #include "magic.h"
    int main ( ) {
      if ( magic ) { spell(); }
      return 0;
    }
    Code:
    // this is magic.c
    #include "magic.h"
    int magic = 1;
    void spell ( ) {
      magic = 0;
    }
    Now, if your project contains only wizard.c, then it will compile just fine, but the linker will FAIL with unresolved symbols - EVEN though you have included the header file.

    Until you tell the compiler about magic.c in some way, say by
    - adding magic.c to the list of source files.
    - adding magic.lib (containing previously compiled magic.c) to the linker library list
    you're just going to be stuck where you are.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

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