#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Need help on linking error in C code!!


    I am working in XP, Visual C++ v6 doing maintenance on existing report preparing codes. I am new to C++ language and to C/C++ programming. I have a linking error and would appreciate some expert help.


    error mssges:
    :\Documents and Settings\IVarma\Desktop\kunda\Modcode.cpp(916) : warning C4508: 'main' : function should return a value; 'void' return type assumed
    Linking...
    Modcode.obj : error LNK2001: unresolved external symbol "int __cdecl open_cluster(void)" (?open_cluster@@YAHXZ)
    Modcode.obj : error LNK2001: unresolved external symbol _BTRV@24
    Modcode.obj : error LNK2001: unresolved external symbol "char * dbpath" (?dbpath@@3PADA)
    Modcode.obj : error LNK2001: unresolved external symbol _fatal
    Modcode.obj : error LNK2001: unresolved external symbol _set_multi_defaults
    Modcode.obj : error LNK2001: unresolved external symbol "char * __cdecl get_option(void)" (?get_option@@YAPADXZ)
    Modcode.obj : error LNK2001: unresolved external symbol "int __cdecl new_decode_cluster(char *,char (* const)[4][100])" (?new_decode_cluster@@YAHPADQAY13GE@D@Z)
    Debug/Modcode.exe : fatal error LNK1120: 7 unresolved externals
    Error executing link.exe.
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,805
    Rep Power
    1570
    The errors all appear to be unresolved dependencies, which means that there are functions and external variables which you are referring to in your code, but which aren't getting included in the list of libraries to link into the program. Where are open_cluster(), get_options(), etc. from? Are they in a library you are using, or another source file which is part of what you're compiling?

    Are you compiling from the command line or in the Visual C++ editor? If the former, can you post the command line you're calling it with, or the make file you're using to build if you have one? If it is the latter, are you certain that the library or object file for these functions is in your project file?
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by Schol-R-LEA
    If it is the latter, [...]
    If it is the latter you can get the same information by holding CTRL and clicking the HTML build log link in the build "Output" window. Post that text.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2007
    Posts
    13
    Rep Power
    0
  8. #5
  9. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,805
    Rep Power
    1570
    Hmmn, yes, that is illuminating fnord. Looking at the code posted in the first message just adds new questions, however.

    First off, is this same code which you are referring to, or is this (as I suspect) a different module version of the program? Modcode.cpp is a C++ program, of course, but if you are simply trying to compile the existing C code as a C++ program, you will almost certainly run into issues of some kind, as already mentioned elsewhere. The error messages, and especially the function prototypes quoted which are defined with the __cdecl modifier, indicate that you're trying to call on a library written in C. Do you actually have this library, already compiled to object code in C?

    Is the new program (Modcode.cpp) a modified version of the code posted earlier (as the name implies)? Can you tell us something about what you're trying to accomplish with it? The original code is 15 years old, and the last listed modification was ten years ago; given that it is financial service software, do the business rules it encodes even still apply, and how do you need to alter them if not? Also, this is a copyrighted, business-related program; did you have permission to post this code publicly from the owners?

    I might add, as a personal comment, that IMAO this is some truly wretched C code. You have my sympathies in trying to maintain it. Some broad refactoring is in order, I think.

    I'll leave it to others to spork you for cross-posting. Suffice it to say that you shouldn't do it again, mmmm'kay?
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo