2

I am justing wondering what the error means here if anyone can help me.

g++ -o Try2 student.o studentlist.o
Undefined                       first referenced
 symbol                             in file
main                                /usr/local/lib/gcc/sparc-sun-solaris2.10/4.8.4/crt1.o
ld: fatal: Symbol referencing errors. No output written to Try2
collect2: error: ld returned 1 exit status
user4581301
  • 33,082
  • 7
  • 33
  • 54
  • Did you first compile the two source files with `g++ -c student.cpp` and `g++ -c studentlist.o`? – Tony Tannous Nov 18 '20 at 05:05
  • Please also show the files –  Nov 18 '20 at 05:08
  • @Tony Tannous Yeah I did. –  Nov 18 '20 at 05:22
  • @Aryan Parekh Both of the .cpp files are around the 300 lines of code and the header are pretty long but i'll try to post them –  Nov 18 '20 at 05:23
  • @Swkn The problem can come from anywhere, try to remove segments of code and see if it suddenly solves the problem. Basically, try making a [mre]. You might find out the reason on your own –  Nov 18 '20 at 05:25
  • @AryanParekh Oh I got what you're saying, I'll be trying that shorty. Thank you for the help! –  Nov 18 '20 at 05:32
  • Does one of your files contain a `main` function? – Alan Birtles Nov 18 '20 at 07:22
  • @AlanBirtles no I don't have a main function in either. –  Nov 18 '20 at 17:22
  • What are you trying to build? If its an executable you need a main function if it isn't you need to either tell gcc you want a static library or use ar to create a static lib – Alan Birtles Nov 18 '20 at 19:50

0 Answers0