This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Newbie compiling -> "undefined reference to" error
- From: tirengarfio <tirengarfio at hotmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 9 Aug 2007 05:41:21 -0700 (PDT)
- Subject: Newbie compiling -> "undefined reference to" error
Hi here,
compiling the main.cpp file below i get this error:
tirengarfio@acergarpe:~/Desktop/Examenes/Prueba$ g++ main.cpp -o main
/tmp/ccey9OCP.o: In function `main':
main.cpp:(.text+0x26): undefined reference to `CPrueba::CPrueba(int)'
collect2: ld devolvià el estado de salida 1
These are the files:
/////CPrueba.h////////
class CPrueba
{
private:
int num;
public:
CPrueba(int numero);
};
/////CPrueba.cpp//////
#include "CPrueba.h"
int CPrueba::CPrueba(int numero)
{
num=numero;
}
/////main.cpp/////
#include "CPrueba.h"
int main()
{
int d=8;
CPrueba obj(d);
}
--
View this message in context: http://www.nabble.com/Newbie-compiling--%3E-%22undefined-reference-to%22-error-tf4242386.html#a12071723
Sent from the gcc - Help mailing list archive at Nabble.com.