c++ - "undefined reference to" in G++ Cpp -


can't seem errors go away. errors below. have looked on google , still can't figure out. not new cpp, have not fooled in while.

weird thing worked g++ in windows...

errors:

  • [ze@fed0r! ---**__*]$ g++ main.cpp
  • /tmp/ccjl2zhe.o: in function `main':
  • main.cpp:(.text+0x11): undefined reference `help::help()'
  • main.cpp:(.text+0x1d): undefined reference `help::sayname()'
  • main.cpp:(.text+0x2e): undefined reference `help::~help()'
  • main.cpp:(.text+0x46): undefined reference `help::~help()'
  • collect2: ld returned 1 exit status

main.cpp

#include <iostream> #include "help.h"  using namespace std;  int main () {      h;     h.sayname();      // ***      // ***      // ***     return 0;  } 

help.h

#ifndef help_h #define help_h  class {     public:         help();         ~help();         void sayname();     protected:     private: };  #endif // help_h 

help.cpp

#include <iostream> #include "help.h"  using namespace std;  help::help() { // constructor }  help::~help() { // destructor }  void help::sayname() {     cout << "            ***************" << endl;     cout << "   ************************************" << endl;     cout << "              ************" << endl;     cout << "         *********************" << endl; } 

g++ main.cpp help.cpp

you have tell compiler files want compile, not first one.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -