Thread: Linking 3 files in Borland C 3.11

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    Unhappy Linking 3 files in Borland C 3.11

    Hello.

    Please help me solve this problem because I'm getting very nervous allready. It's very simple, but still it gives me a bad headache.

    I have 3 files:
    1) classX.h - contains declaration of class X
    2) classX.cpp - contains definition of class X
    3) main.cpp - very simple main program that uses class X

    And you're allready guessing I want to link them into one exe file.
    The problem is, I'm bound to use BorlandC 3.11 compiler (which is new to me), and I still don't believe I didn't manage to do it myself, but it's true.
    All 3 files are in the same directory C:\BC31\BIN, search paths for include and library files are correct, and point to that dir, but still command
    Code:
     bcc classX.cpp main.cpp
    returns message:
    Code:
      error: undefined symbol X::geta() in module main.cpp
    where getA is method in class X.

    Please, if you know the answer, I will appreciate it very much.

    Buy.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Brain Damage
    returns message:
    Code:
      error: undefined symbol X::geta() in module main.cpp
    where getA is method in class X.
    Typo?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Does main.cpp have #include "classX.h"

    > All 3 files are in the same directory C:\BC31\BIN
    Bad idea - create a separate directory (say c:\code) where all your code lives. There's no need to store your source code in the same directory as your compiler, if you've set everything up.

    Also, does compiling a simple "hello world" type program compile OK?

    > The problem is, I'm bound to use BorlandC 3.11 compiler
    Never a good sign, if your tutor insists on using a particular compiler, especially an old one.
    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.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    3
    Quote Originally Posted by Dave_Sinkula
    Typo?
    No, it's not that simple.
    Quote Originally Posted by Salem
    Does main.cpp have #include "classX.h"
    Of course it has, because compiler doesn't complain.

    Quote Originally Posted by Salem
    > All 3 files are in the same directory C:\BC31\BIN
    Bad idea - create a separate directory (say c:\code) where all your code lives. There's no need to store your source code in the same directory as your compiler, if you've set everything up.
    I agree it's a bad idea, but it was just for the testing purposes.
    Now, I've tried to put those files in c:\code and modify search paths, but problem remains the same.

    Quote Originally Posted by Salem
    Also, does compiling a simple "hello world" type program compile OK?
    Yes, as long as everything is in the same file (or one .cpp file (main program) and one header) it's OK. Linking is the problem.

    Quote Originally Posted by Salem
    > The problem is, I'm bound to use BorlandC 3.11 compiler
    Never a good sign, if your tutor insists on using a particular compiler, especially an old one.
    I don't like it either.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Can you post your 3 files, or 3 smaller versions of the files which demonstrate the same problem.
    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.

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    3
    Thank you, thank you very much.

    I thought that problem is most certanly in command line parameters, .cfg files, or something like that. Now, you made me recheck the code, so I found the error, subtle but important.
    The bug was inline specifier in method definition(in classX.cpp file). Why that is fine with compiler, and makes problems during linking, don't know and it doesn't matter.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  2. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  3. Linking Error Whenever I Tried To Use Header Files
    By javacvb in forum C++ Programming
    Replies: 5
    Last Post: 12-16-2003, 11:46 AM
  4. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM