0

I am using Netbeans for my C++ project. I compiled my program using make and ran into this error:

collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
Makefile:4: recipe for target 'barn' failed
make: *** [barn] Error 1

Whereas, when I compiled it in a linux environment(Ubuntu to be precise), it compiled fine. What could have possibly gone wrong?

This is what I got when I typed make -n:

g++ -c main.cc
g++ -c Animal.cc
g++ -c Bird.cc
g++ -c Chicken.cc
g++ -c Cat.cc
g++ -c Pig.cc
g++ -o barn main.o Animal.o Bird.o Chicken.o Cat.o Pig.o Random.o

PS I prefer using Netbeans

user3450695
  • 2,281
  • 4
  • 16
  • 16

1 Answers1

1

A segment fault in the linker suggests a bug with that. This is what I would try if I were to run into this problem.

At the command line do

g++ -o barn main.cc Animal.cc Bird.cc Chicken.cc Cat.cc Pig.cc Random.cc

If that does not work, try variations like:

g++ -o barn main.cc Pig.cc Random.cc Animal.cc Bird.cc Chicken.cc Cat.cc 

The order should not matter. This is just the kind of thing I would try with a mystery-meat problem like this.

user3344003
  • 20,574
  • 3
  • 26
  • 62