Mail Archives: djgpp/1997/12/23/21:00:30
I try to make little class in C++ to test makefile and compilation with
DJGPP. This little class don't link and I don't what is the reason of
this problem.
I put in the message C++ code and errors gernerate by compilation.
Thank you
GRS
main.cpp:
#include <iostream.h>
#include "test.h"
int main()
{
int x,y;
cout << "entrez une valeur de x: ";
cin >> x;
cout << endl;
cout << "entrez une valeur de y: ";
cin >> y;
cout << endl;
cout << somme(x,y) << endl;
cout << soust(x,y) << endl;
return 0;
}
classe test
test.h:
#ifndef test_flag
#define test_flag
class test {
public:
int somme(int,int);
int soust(int,int);
test();
};
#endif test_flag
test.cpp
#include <iostream.h>
#include "test.h"
test::somme(int val1,int val2)
{
return val1+val2;
}
test::soust(int val1,int val2)
{
return val1-val2;
}
test::test()
{
}
#fichier makefile pour test
test : main.o test.o
gxx -o test main.o test.o
main.o : main.cpp test.h
gxx -c main.cpp
test.o : test.cpp test.h
gxx -c test.cpp
errors:
cd c:/prog/
make -k
gxx -c test.cpp
gcc.exe: -lgpp: linker input file unused since linking not done
gcc.exe: -lstdcx: linker input file unused since linking not done
gcc.exe: -lm: linker input file unused since linking not done
gxx -o test main.o test.o \
main.o(.text+0xc5):main.cc: undefined reference to `somme'
main.o(.text+0xf7):main.cc: undefined reference to `soust'
make.exe: *** [test] Error 1
--
Geoffroy Rivet-Sabourin
Etudiant en Genie informatique
Universite Laval Quebec, Canada
- Raw text -