Im having linking problems with turbo c++ ver 4.5

This is a discussion on Im having linking problems with turbo c++ ver 4.5 within the C++ Programming forums, part of the General Programming Boards category; Background: I am a newbie to programming. I just started using this compiler, I used to use visual c++ .NET ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    Im having linking problems with turbo c++ ver 4.5

    Background:
    I am a newbie to programming.
    I just started using this compiler, I used to use visual c++ .NET and I never had any linking problems there.

    Problem:
    I tried out with a simple program about a buffer and I got thease errors:
    Code:
    Linker Warning: No module definition file specified: using defaults
    Linker Error: Undefined symbol Buffer::~Buffer() in Module Main.cpp
    Linker Error: Undefined symbol Buffer::DisplayBuff() in Module Main.cpp
    Linker Error: Undefined symbol  Buffer::ClearBuff() in Module Main.cpp
    Linker Error: Undefined symbol Buffer::Buffer() in Module Main.cpp
    Now here is the program:

    Main.cpp
    Code:
    #include "Buffer.h"
    
    int main()
    {
    	Buffer a;
    
    	a.ClearBuff();
    	a.DisplayBuff();
    
    	return 0;
    }
    Buffer.h
    Code:
    #ifndef BUFFER_H
    #define BUFFER_H
    
    //class Buffer
    class Buffer {
    public:
    	Buffer();
    	~Buffer();
    
    	void Add(int Pos, char *b);
    	void ClearBuff();
    	void DisplayBuff();
    
    private:
    	char *a;
    };
    
    #endif
    Buffer.cpp
    Code:
    #include <iostream.h>
    #include <string.h>
    #include "Buffer.h"
    
    Buffer::Buffer()
    {
    	a = new char[1999];
    }
    
    Buffer::~Buffer()
    {
    	delete[] a;
    }
    
    void Buffer::Add(int Pos, char *b)
    {
    	int i = 0;
    
    	for (i = 0; i < strlen(b); i++)
    	{
    		if (Pos+i > 1999 || Pos+i < 0)
    			return;
    		a[Pos+i] = b[i];
    	}
    }
    
    void Buffer::ClearBuff()
    {
    	int i = 0;
    
    	for (i = 0; i < 1999; i++)
    		a[i] == ' ';
    }
    
    void Buffer::DisplayBuff()
    {
    	int i = 0;
    
    	for (i = 0; i < 1999; i++)
    		cout << a[i];
    }
    Sorry for bothering you guys but I really would like to fix this problem. Thanks for any help.
    Last edited by Marcos; 05-17-2004 at 03:04 PM.
    Why drink and drive when you can smoke and fly?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    You need to compile and link Buffer.cpp

    gg

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Thanks very much that solved those problems but now there is a new more disturbing one:
    Code:
    Linker Error: Undefined symbol _main in library file C:\TCWIN45\LIB\cwb.lib in module winmain
    I compiled all the files and I get no errors.
    I tried linking all the files and I always get that error except when I link Main.cpp I get the same errors from before :/
    Why drink and drive when you can smoke and fly?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    You have to link them all at the same time.....

    What is cwb.lib and why are you linking with it?

    I'm not familiar with TC 4.5 or it's IDE so I can help much except to explain what the compiler and linker errors mean.

    gg

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    well thats the thing I have no idea what cwb.lib is, I just right click on the file (Buffer.h, Buffer.cpp and Main.cpp) and click on link, I never have a choice what to link them with.
    Why drink and drive when you can smoke and fly?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linking problems
    By chris285 in forum C++ Programming
    Replies: 6
    Last Post: 01-09-2005, 12:39 AM
  2. Linking problems
    By MMD_Lynx in forum C++ Programming
    Replies: 12
    Last Post: 08-10-2004, 10:32 AM
  3. Linking Problems
    By Mini_Maggit in forum C++ Programming
    Replies: 3
    Last Post: 03-11-2004, 10:06 PM
  4. Linking problems
    By jamjar in forum C++ Programming
    Replies: 10
    Last Post: 03-28-2003, 02:07 AM
  5. Borland Turbo C/C++ V3.0 Problems
    By Mezzair in forum C Programming
    Replies: 1
    Last Post: 11-06-2002, 05:10 PM

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