0
나는 내 프로그램에서이 오류를 여러 번 얻었습니다. 기본 사항을 설명하기 위해 문제를 단순화했으며 여전히 오류가 발생하고 있습니다. 나는 libncurses.dylib가 작동하도록이 라이브러리 파일을 프로젝트에 추가해야한다고 말했지만 몇 가지 문제는 해결했지만이 문제는 해결하지 못했습니다.curses.h와 함께 Apple Mach-O Link 오류
// screen.h
#ifndef screen_h
#define screen_h
#define MAC 1
#define WIN 2
#define LNX 3
#ifdef PLATFORM
#undef PLATFORM
#endif
#define PLATFORM MAC
void screen_erase();
#endif
// screen.c
#include <string.h>
#include <stdlib.h>
#include "screen.h"
#if PLATFORM == MAC
#include <curses.h>
void screen_erase(){
erase();
}
#endif
// MAIN.CPP
#include <iostream>
#include <curses.h>
#include "screen.h"
using namespace std;
int main(){
screen_erase();
}
그리고 다음은
내 코드입니다 여기에 내가 얻는 오류가있다 :Undefined symbols for architecture x86_64:
"screen_erase()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation
여기 무슨 일 이니?
각 파일 및 링크 라인의 컴파일을 표시해야합니다. Joachim이 진단 한 것처럼, C++ 컴파일러에게 C linkage --extern "C"void screen_erase (void);가있는 함수임을 알리지 않고 C 함수를 호출하는 것처럼 보입니다. 그리고 그것은 C 컴파일러에 의해 이해되지 않기 때문에, 당신도 그것을 해결해야 할 것입니다. –