I\'m getting some problems on compiling a very very simple name.c file on Mac OSX Lion.
Now, I started following Harvard CS50 course on cs50.net. I\'m not totally ne
The problem you encounter is in the linking stage, not compiling. You did not provide the implementation of GetString
, only its declaration (through the .h
file you #include
).
To provide the implementation itself, you usually need to link against the library which includes it; this is usually done by the -l
flag to g++
. For example,
g++ file.cpp -lcs50
Your second sample code does link, because you manually (and explicitly) provide an implementation for GetString
, though an empty one.