Mail Archives: djgpp/2000/02/12/13:59:07
itmiller AT dera DOT gov DOT uk (Ian Miller) writes:
> Have you tried writing a *really* simple library? Containing one class with
> just a constructor and destructor that both just write to cout, say. Then
> you could try to link a tiny program to that library and at least confirm
> that you can do this at all.
I just tried this out. here's what it looks like:
LIBTEST.A consists of 2 files, a header and a source:
//TEST.H
class test_class
{
void test_message(void);
};
//TEST.CPP
#include <iostream.h>
#include "test.h"
void test_class::test_message(void)
{
cout << "My library doesn't work!";
}
This library builds correctly. Now here is my simple library-testing program
("test" is checked off in RHIDE's library menu):
//TESTPROG.CPP
#include <iostream.h>
#include "test.h"
void main()
{
test_class test_object;
test_object.test_message();
}
This program compiles correctly with the command:
gcc -g -c testprog.cpp -o testprog.o
And LINKS correctly too with the command:
gcc -o testprog.exe testprog.o -ltest -lstdcx
(note that "-lstdcx" SHOULD say "-lstdcxx", but I changed the name to be 1
character shorter to deal with the long file name problem - it works fine now
though)
So now I know that a simple library will work - there must be something wrong
with my code. nick AT arcticmail DOT com suggested that the order in which the
libraries are linked is important - object files, user libraries, then the
standard libraries, but I checked and this is the order I do it in. Anybody
have any suggestions on where to start looking in my code? :) thanx again
for all your support
-Kevin
- Raw text -