Solved

Borland Classlib with TCWin45

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 415
White board coding practice 3 88
Unable to start eclipse ? 17 141
max float value 3 41
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 clear a vector as well as how to detect empty vectors in C++.

777 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