C - Undefined symbols for architecture x86_64 when compiling on Mac OSX Lion

后端 未结 1 1520
青春惊慌失措
青春惊慌失措 2021-01-04 07:13

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

相关标签:
1条回答
  • 2021-01-04 08:08

    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.

    0 讨论(0)
提交回复
热议问题