Note that there are some explanatory texts on larger screens.

plurals
  1. POC - Undefined symbols for architecture x86_64 when compiling on Mac OSX Lion
    primarykey
    data
    text
    <p>I'm getting some problems on compiling a very very simple name.c file on Mac OSX Lion.</p> <p>Now, I started following Harvard CS50 course on cs50.net. I'm not totally new to programming but I was curious on how this course has been taught. </p> <p>This is the source of name.c:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;cs50.h&gt; int main(void) { printf("State your name:\n"); string name = GetString(); printf("O hai, %s!\n", name); return 0; } </code></pre> <p>As you can see, it requires this library: <a href="https://manual.cs50.net/CS50_Library" rel="nofollow noreferrer">https://manual.cs50.net/CS50_Library</a>.</p> <p>Now, when I compile it, this happens:</p> <pre><code>Undefined symbols for architecture x86_64: "_GetString", referenced from: _main in name-vAxcar.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: *** [name] Error 1 </code></pre> <p>If I use the same GetString() cs50.c function inside my source file, it works perfectly:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;float.h&gt; #include &lt;limits.h&gt; #include &lt;stdbool.h&gt; #include &lt;stdlib.h&gt; typedef char *string; string GetString(void); int main(void) { printf("State your name:\n"); string name = GetString(); printf("O hai, %s!\n", name); } string GetString(void) { // CODE } </code></pre> <p>Why does this happen? I installed the library as it says on the link above; I checked and both cs50.h and libcs50.a are respectively in /usr/local/include and /usr/local/lib.</p> <p>Thank you in advance for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload