Solved

Borland Classlib with TCWin45

Posted on 1997-01-07
1
1,542 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now