0

I'm trying to learn C++ using Xcode however the line #include "Sales_item.h" produces an error. Both files are in the same directory which is the project open in Xcode. I cannot figure out how to set the header search path in Xcode which may be the problem. Here is all of the code:

#include <iostream>
#include "Sales_item.h"

int main()
{
    Sales_item book;
    std::cin >> book;
    std::cout << book << std::endl;
    return 0;
}
  • "operator< >&, Sales_item const&)", referenced from: "operator>>(std::__1::basic_istream >&, Sales_item&)", referenced from: clang: error: linker command failed with exit code 1 (use -v to see invocation) – Tyler Bloom Sep 21 '17 at 02:18
  • the error is definitely from the line I mentioned and it is not a typo error I have been trying to figure this out for many hours – Tyler Bloom Sep 21 '17 at 02:19
  • This seem to be a linker error, where the linker is looking for `operator< – Bo Persson Sep 21 '17 at 02:26
  • What is a linker? How do I implement the file? The file is in the project – Tyler Bloom Sep 21 '17 at 02:38
  • these are the contents of the folder which is open in xcode, the latter containing the code I wrote in the question: Sales_item.h main.cpp – Tyler Bloom Sep 21 '17 at 02:39
  • A linker is a program that pulls together several compiled files and builds the program file from those. It tries to fix things like calling a function in another file. "Implement" just means "to write the code". :-) One way to get your problem is to use a function or operator that you haven't written yet. But there are many other ways: [What is an undefined reference?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Bo Persson Sep 21 '17 at 02:51
  • Ok so how do I get the linker within Xcode to pull the file Sales_item.h? – Tyler Bloom Sep 21 '17 at 03:39

0 Answers0