Board index » cppbuilder » #include problem

#include problem


2003-09-08 08:35:57 AM
cppbuilder13
Hello,
This is a really basic problem, but I can't solve it so please help!
I'm using the Borland C++ 5.5 command line compiler.
Have three files to show the problem: t1.h, t1.cpp and test1.cpp. test1.cpp
#includes t1.h, and so does t1.cpp - just like the books on the C++ course
I'm doing show.
When I try to compile (command line: bcc32 -v -A- test1.cpp) I get the
following:
C:\test>bcc32 -v -A- test1.cpp
Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
test1.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'test::test()' referenced from C:\TEST\TEST1.OBJ
Error: Unresolved external 'test::dosomething()' referenced from
C:\TEST\TEST1.OBJ
C:\test>
I must have something configured wrongly? The bcc32.cfg and ilink32.cfg
files are:
bcc32.cfg:
-I"C:\Borland\bcc55\include"
-L"C:\Borland\bcc55\lib"
-L"c:\Borland\Bcc55\lib"
and the same fault occurs if I take away the double quotes.
Thanks!
Chris
t1.h
========================================
// t1.h
//
// t1 test class
#ifndef T1_H
#define T1_H
class test
{
public:
test(); // default constructor
void dosomething();
}; // end class test
#endif
========================================
t1.cpp
========================================
// t1.cpp
//
// test class
#ifndef T1_H
#include "t1.h"
#endif
#include <iostream>
using std::cout;
using std::endl;
test::test()
{
} // end test constructor
void test::dosomething()
{
cout << "It works..." << endl;
} // end dosomething
========================================
test1.cpp
========================================
// test1
#include <iostream>
using std::cout;
using std::endl;
#include "t1.h"
main()
{
test t3;
t3.dosomething();
}
========================================
 
 

Re:#include problem

Hello,
This is a really basic problem, but I can't solve it so please help!
I'm using the Borland C++ 5.5 command line compiler.
Have three files to show the problem: t1.h, t1.cpp and test1.cpp. test1.cpp
#includes t1.h, and so does t1.cpp - just like the books on the C++ course
I'm doing show.
When I try to compile (command line: bcc32 -v -A- test1.cpp) I get the
following:
C:\test>bcc32 -v -A- test1.cpp
Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
test1.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'test::test()' referenced from C:\TEST\TEST1.OBJ
Error: Unresolved external 'test::dosomething()' referenced from
C:\TEST\TEST1.OBJ
C:\test>
I must have something configured wrongly? The bcc32.cfg and ilink32.cfg
files are:
bcc32.cfg:
-I"C:\Borland\bcc55\include"
-L"C:\Borland\bcc55\lib"
-L"c:\Borland\Bcc55\lib"
and the same fault occurs if I take away the double quotes.
Thanks!
Chris
t1.h
========================================
// t1.h
//
// t1 test class
#ifndef T1_H
#define T1_H
class test
{
public:
test(); // default constructor
void dosomething();
}; // end class test
#endif
========================================
t1.cpp
========================================
// t1.cpp
//
// test class
#ifndef T1_H
#include "t1.h"
#endif
#include <iostream>
using std::cout;
using std::endl;
test::test()
{
} // end test constructor
void test::dosomething()
{
cout << "It works..." << endl;
} // end dosomething
========================================
test1.cpp
========================================
// test1
#include <iostream>
using std::cout;
using std::endl;
#include "t1.h"
main()
{
test t3;
t3.dosomething();
}
========================================
 

Re:#include problem

To compile only put a -c on the command line to the left of the first file
name. If you do not put -c on the command line then the compiler will call
the linker and try to create an exe file.
So, assuming that t1.cpp and test1.cpp are needed to create the program you
could do any of these to create test1.exe
compile them both and link
bcc32 -v test1 t1
or
compile one then compile the 2nd along with the object file from the first
and link
bcc32 -c -v test1
bcc32 -v t1 test1.obj
or
compile each and then use the compiler to link to an exe
bcc32 -c -v test1
bcc32 -c -v t1
bcc32 -v test1.obj t1.obj
or
compile each and do the linking yourself
bcc32 -c -v test1
bcc32 -c -v t1
ilink32 /Tpe/ap/x/v/Gn c0x32 test1 t1,test1,,import32 cw32
. Ed
Quote
Chris McCray wrote in message
news:3f5bcf28$ XXXX@XXXXX.COM ...

This is a really basic problem, but I can't solve it so please help!

I'm using the Borland C++ 5.5 command line compiler.

Have three files to show the problem: t1.h, t1.cpp and test1.cpp.
test1.cpp #includes t1.h, and so does t1.cpp - just like the books
on the C++ course I'm doing show.

When I try to compile (command line: bcc32 -v -A- test1.cpp) I
get the following:

C:\test>bcc32 -v -A- test1.cpp
Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
test1.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'test::test()' referenced from
C:\TEST\TEST1.OBJ
Error: Unresolved external 'test::dosomething()' referenced from
C:\TEST\TEST1.OBJ
 

{smallsort}

Re:#include problem

Thanks Ed!
It works and compiles first time.
Cheers,
Chris
"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
To compile only put a -c on the command line to the left of the first file
name. If you do not put -c on the command line then the compiler will
call
the linker and try to create an exe file.

So, assuming that t1.cpp and test1.cpp are needed to create the program
you
could do any of these to create test1.exe

compile them both and link
bcc32 -v test1 t1

or
compile one then compile the 2nd along with the object file from the first
and link
bcc32 -c -v test1
bcc32 -v t1 test1.obj

or
compile each and then use the compiler to link to an exe
bcc32 -c -v test1
bcc32 -c -v t1
bcc32 -v test1.obj t1.obj

or
compile each and do the linking yourself
bcc32 -c -v test1
bcc32 -c -v t1
ilink32 /Tpe/ap/x/v/Gn c0x32 test1 t1,test1,,import32 cw32

. Ed

>Chris McCray wrote in message
>news:3f5bcf28$ XXXX@XXXXX.COM ...
>
>This is a really basic problem, but I can't solve it so please help!
>
>I'm using the Borland C++ 5.5 command line compiler.
>
>Have three files to show the problem: t1.h, t1.cpp and test1.cpp.
>test1.cpp #includes t1.h, and so does t1.cpp - just like the books
>on the C++ course I'm doing show.
>
>When I try to compile (command line: bcc32 -v -A- test1.cpp) I
>get the following:
>
>C:\test>bcc32 -v -A- test1.cpp
>Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
>test1.cpp:
>Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
>Error: Unresolved external 'test::test()' referenced from
>C:\TEST\TEST1.OBJ
>Error: Unresolved external 'test::dosomething()' referenced from
>C:\TEST\TEST1.OBJ