Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking virtual class 1

Status
Not open for further replies.

jstreich

Programmer
Apr 20, 2002
1,067
0
0
US
I'm compiling with g++, and I have a abstract class:

Code:
class listener
{
  public:
    listener(){}
    virtual ~listener(){};
    virtual void actionPerformed(void* event,void* actor)=0;
  private:
    listener(const listener& l){}
};

when I try to compile it into a project I get an object file, but when compiling and linking I get:

Code:
listener.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status

I'm compiling using:

Code:
g++ -c -g joystick.c -o joystick.o
g++ -c -g serial.c -o serial.o
g++ -c -g listener.h -o listener.o
g++ -c -g jslistener.c -o jslistener.o
g++ -c -g xbeejslistener.c -o xbeejslistener.o
g++ -c -g driver.c -o driver.o
g++ driver.o xbeejslistener.o jslistener.o serial.o joystick.o listener.o -o joydriver

What am I doing wrong?

[plug=shameless]
[/plug]
 
Try changing .h to either .cpp or .cxx. g++ is actually a wrapper for gcc.
 
you can also try to use -x option so that .h or .hpp can be read.
 
Better don't compile .h files separately, especially .h files with class definitions only (it does not matter abstract or concrete). No need to do that at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top