Solved

Borland Classlib with TCWin45

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 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

24 Experts available now in Live!

Get 1:1 Help Now