0
세 개의 파일이있는 간단한 프로젝트가 있습니다. Main.cpp, CountTriangles.cpp 및 CountTriangles.hpp. 빌드/실행하려고하면 "링커 명령이 종료 코드 1과 함께 실패했습니다."라는 메시지가 표시되고 로그에서 "x86_64 아키텍처의 ld : 1 중복 심볼"을 찾습니다.링커 명령이 실패했습니다. 중복 된 심볼
는 MAIN.CPP :
#include "CountTriangles.cpp"
int main(int argc, const char * argv[]) {
return 0;
}
CountTriangles.cpp :
#include "CountTriangles.hpp"
using namespace std;
int TriangleCount::count(int N){
int helper = 1;
return helper;
}
CountTriangles.hpp : main.cpp
에서
#ifndef CountTriangles_hpp
#define CountTriangles_hpp
#include <iostream>
#include <stdio.h>
class TriangleCount{
public:
int count(int N);
};
#endif /* CountTriangles_hpp */
헤더 파일이 아닌 * 소스 파일을 포함합니다. 그러지 마. –
주에서는 .hpp 파일 대신'#include "CountTriangles.cpp"를 포함합니다. –
앞으로의 질문은 좋은 질문을하는 방법을 읽어보십시오.] (http://stackoverflow.com/help/how-to-ask). 오류 출력을 실제로 복사 * 붙여 넣기 *해야합니다. 존재할 수있는 정보 메모가 완전하고 완성됩니다. –