Solved

Borland Classlib with TCWin45

Posted on 1997-01-07
1
1,552 Views
Last Modified: 2008-03-03
I have problems using the Borland Classlib. The classlib files
are in the direcotry "c:\tcwin45\include\classlib\obsolete".
I am using Borland Turbo C++ V4.5 unde win95. I am trying to
compile an EasyWin program.
--------------------------------------------
I if enter a simple! code like this:

#include "c:\tcwin45\include\classlib\obsolete\SortArry.h"

int main()
{
     SortedArray a(3);

     return 0;
}

I get a sea of linker errors (20+) and just as many linker
warnings. This happens when ever I try to use the Classlib.
I have tried several exampels from the actual classlib and
none work. EI:

#include "c:\tcwin45\include\classlib\obsolete\strng.h"
#include "c:\tcwin45\include\classlib\obsolete\array.h"

int main()
{
      Array a(2);
      String *s1 = new String("a string");
      String *s2 = new String("another string");

      a.add(*s1);
      a.add(*s2);

      return 0;
}

When I compile that code, I get the following error messages:

Compiling TST_STR.CPP:
Linking tst_str.exe:
Linker Warning: No module definition file specified: using defaults
Linker Warning: Possible reference to undefined extern Object::ZERO in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::~AbstractArray() in module TST_STR.CPP
Linker Error: Undefined symbol Array::add(Object far&) in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::AbstractArray(int,int,unsigned int) in module TST_STR.CPP
Linker Error: Undefined symbol Object::ZERO in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::printContentsOn(ostream far&) const in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::detach(int,Object::TShouldDelete::DeleteType) in module TST_STR.CPP
Linker Error: Undefined symbol Collection::findMember(Object far&) const in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::detach(Object far&,Object::TShouldDelete::DeleteType) in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::initIterator() const in module TST_STR.CPP
Linker Error: Undefined symbol Container::printTrailer(ostream far&) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::printSeparator(ostream far&) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::printHeader(ostream far&) const in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::flush(Object::TShouldDelete::DeleteType) in module TST_STR.CPP
Linker Error: Undefined symbol Container::printOn(ostream far&) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::lastThat(int(far*)(const Object far&,void far*),void far*) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::firstThat(int(far*)(const Object far&,void far*),void far*) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::forEach(void(far*)(Object far&,void far*),void far*) in module TST_STR.CPP
Linker Error: Undefined symbol AbstractArray::isEqual(const Object far&) const in module TST_STR.CPP
Linker Error: Undefined symbol Container::hashValue() const in module TST_STR.CPP

What is wrong?

-= Christian
0
Comment
Question by:Christian Reimer
1 Comment
 

Accepted Solution

by:
isc earned 50 total points
ID: 1162192
There are a couple of problems here that I see. First, the linker errors tell me that the "newer", pass by reference array classes have been defined and are being used. Under TargetExpert, I expect you will see that the "Class Libraries" checkbox is checked. You will have to uncheck this and explicitly add the obsolete class libraries to your project. You will have to re-create this library if it doesn't exist; or you could simply add the source code .cpp files to your project. This should permit your project to link properly.

However, it still appears that the newer class library header files are being included somewhere. Look for any other regular OWL header files being included.

These problems are due to the fact that while the obsolete class libraries are available to you, they are not inherently supported without a lot of effort. I would suggest that you consider the newer class libraries in a BC example such as this:

// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// iarray.cpp
//    Must link with myclass.cpp.                    
// ---------------------------------------------------------------------------

#include <classlib/arrays.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"

typedef TIArrayAsVector<MyClass> ContainerType;
typedef TIArrayAsVectorIterator<MyClass> IteratorType;

const int MaxItems=6;

void ForEachCallBack(MyClass& mc, void* s)
{
    cout << (char*)s << mc << endl;
}

void AddItems(ContainerType& container, int numItems)
{
    for( int i=numItems; i>0; i-- )
        {
        char buf[80];
        ostrstream str( buf, sizeof(buf) );
        str << i << " hello" << ends;
        container.Add( new MyClass(buf) );
        }
}

void UseForwardIterator(ContainerType& container)
{
    IteratorType iterator(container);
    while( iterator )
        {
        cout << *iterator.Current() << endl;
        iterator++;
        }
}

void UseIndex(ContainerType& container)
{
    for( int i=container.LowerBound(); i<container.UpperBound(); i++ )
        cout << *container[i] << endl;
}

int main()
{
    ContainerType container(MaxItems);
    AddItems(container, MaxItems);
 
    cout << "--- Starting ForEach" << endl;
    container.ForEach(ForEachCallBack, (void*)"FE ");
 
    cout << "--- Starting Iterator (forward)" << endl;
    UseForwardIterator(container);
 
    cout << "--- Using operator[]" << endl;
    UseIndex(container);
 
    return 0;
}

I got this from the examples directory. The MyClass files are included here but they should be included in the distribution set.


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question