0

Class makefile

Hi. Instead of including “Myclas.h” I’m including “Myclas.cpp” and it works only like that. Otherwise an error shown “undefined reference to ‘Myclas::Myclas()’ And it’s a public constructor. In Myclas.cpp file I have Myclas.h and Myclas::Myclas(); Don’t understand.

15th Dec 2018, 12:43 PM
Nazar
4 Answers
+ 1
You should NEVER EVER include a cpp file. The undefined occurred because you might have forgotten to add your cpp file in the compilation command line. Can you show your makefile to be sure please ?
15th Dec 2018, 4:11 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
I do not found errors in your Makefile, can you show Myclas.cpp/.h please ?
16th Dec 2018, 4:58 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
it works now. i did a mistake in a Myclas word instead heving Myclas i had Myclass. thanks for help
16th Dec 2018, 7:26 PM
Nazar
0
Thanks for an aswer. Makefike output: Myclas.o Simplerun.o g++ Myclas.o Simplerun.o -o output main.o: Simplerun.cpp g++ -c Simplerun.cpp myclas.o: Myclas.cpp Myclas.h g++ -c Myclas.cpp I’ve ran it on SublimeText compiler and on mingw compiler.
15th Dec 2018, 10:49 PM
Nazar