I am very new to C++, and I have been completing the exercises for the Stanford 106B CS class. I've found a lot of posts here and elsewhere with a similar problem to mine, but none that could help me out with my specific issue. The Stanford 106B class uses the StanfordCPPlib, or Stanford c++ libraries, which I downloaded. I am trying to complete an exercise that requires me to #include "random.h" so I can use a method for finding a random real number between 0 and 1. Anyways, simply writing #include "random.h" and the rest of the necessary code in text file doesn't work. I am getting this error:
make random
c++ random.cpp -o random
Undefined symbols for architecture x86_64:
"randomReal(double, double)", referenced from:
_main in random-BBexsD.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [random] Error 1
The Stanford class uses Xcode, and the homework assignments downloaded from the website have Xcode projects already set up to run with the Stanford libraries. There is also a blank Xcode project template to use for the text book exercises. However, I am trying to figure out how to do this in a text editor or terminal or both. I usually write all my code using a text editor and executing it in terminal. I have tried writing #include "file_path_to_stanford_libraries/random.h", which I'm not even sure works in a .cpp file, but I tried it to no avail. I tried putting the files in the exact same directory as my random.cpp file, which also didn't work. Sorry for this long, and hopefully, not inane post. I appreciate any help.