Mac OSX Lion에서 매우 간단한 name.c 파일을 컴파일하는 데 문제가 있습니다.C - Mac OSX Lion에서 컴파일 할 때 x86_64 아키텍처에 대한 정의되지 않은 기호
이제 저는 cs50.net에서 하버드 CS50 과정을 시작했습니다. 나는 완전히 프로그래밍에 익숙하지는 않지만이 과정이 어떻게 가르쳐 졌는지 궁금했다.
이
이 name.c의 원인 : 당신이 볼 수 있듯이#include <stdio.h>
#include <cs50.h>
int
main(void)
{
printf("State your name:\n");
string name = GetString();
printf("O hai, %s!\n", name);
return 0;
}
,이 라이브러리가 필요합니다 : https://manual.cs50.net/CS50_Library. 나는 그것을 컴파일 할 때
이제,이 상황이 발생합니다
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
내 소스 파일 내에서 동일하여 GetString() cs50.c 기능을 사용하는 경우, 그것은 완벽하게 작동합니다 :
#include <stdio.h>
#include <string.h>
#include <float.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
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
}
왜 이것이 일어날까요? 위의 링크에 표시된대로 라이브러리를 설치했습니다. 나는 cs50.h와 libcs50.a가 각각/usr/local/include와/usr/local/lib에 있는지 확인했다.
도움을 주셔서 감사합니다.
'-lcs50'을 컴파일러에 전달하고 있습니까? – apmasell
컴파일러에게'-lcs50'을 찾을 곳을 알려주는 적절한'-L'? –
twalberg