Although have some questions with the same title but, I believe that my problems are little different.
I have 3 files: main.cpp, car.h and car.cpp.
main.cpp:
#include <string>
#include <iostream>
#include "car.h"
int main(int argc, const char * argv[]) {
Car v;
std::cout << v.getName() << std::endl;
return 0;
};
car.h
#include <string>
#include <iostream>
#ifndef CAR_H
#define CAR_H
class Car {
public:
std::string getName();
};
#endif // MAINWINDOW_H
car.cpp
#include "car.h"
std::string Car::getName() {
return "blah";
};
When i run in terminal with "g++ main.cpp", i got this strange message:
Undefined symbols for architecture x86_64:
"Car::getName()", referenced from:
_main in main-b1d04e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
It's a newbie question, but could anyone help me?