최근에 C++로 새 프로젝트를 시작했습니다. 문제는 컴파일 할 때 링크 오류가 발생한다는 것입니다. 오늘 하루 종일 디버깅하려했지만 어디서나 좋은 해결책을 찾지 못했습니다. 누군가가 그것을 도울 수 있다면 그것은 놀랄 것입니다. Mac Sierra를 사용하고 있습니다.아키텍처에 대한 기호가 없습니다. x86_64 - Cmake - Mac sierra
parsing/methylation.h
#ifndef EPIRL_METHYLATION_H
#define EPIRL_METHYLATION_H
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
namespace methylation {
struct MethLine {
string chr;
int coord;
char strand;
int methylated;
int un_methylated;
string context;
string tag;
};
string calculateMethylationByContext(
MethLine m_input[], int length,
int window_start, int window_end, int threshold);
void calculateMethylation(
const istream &methylation_stream,
const istream &coordinate_stream,
const ostream &output_stream
);
}
#endif //EPIRL_METHYLATION_H
parsing/methylation.cpp
#include "methylation.h"
namespace methylation {
string calculateMethylationByContext(
MethLine m_input[], int length,
int window_start, int window_end, int threshold) {
// rest of the code ...
}
}
main.cpp
#include <iostream>
#include <fstream>
#include "parsing/methylation.h"
using namespace std;
int main(int argc, char **argv) {
if (argc != 4) {
cout << "Invalid number of arguments..." << endl;
return 1;
}
char *methylation_file = argv[1];
char *coordinate_file = argv[2];
char *output_file = argv[3];
ifstream methylation_file_stream(methylation_file, ios::binary);
ifstream coordinate_file_stream(coordinate_file, ios::binary);
ofstream output_file_stream(output_file, ios::binary);
methylation::calculateMethylation(methylation_file_stream,
coordinate_file_stream, output_file_stream);
methylation_file_stream.close();
coordinate_file_stream.close();
output_file_stream.close();
return 0;
}
,745,
코딩에 CLion을 사용합니다. 나는 그것을 구축 할 때, 내 cmake 명령은 잘 작동하지만 내가 다음을 클릭합니다 때 다음과 같은 오류 얻을 '확인'
cmake_minimum_required(VERSION 3.6)
project(src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
parsing/methylation.cpp
parsing/methylation.h
main.cpp)
add_executable(src ${SOURCE_FILES})
:
Undefined symbols for architecture x86_64:
"methylation::calculateMethylation(std::__1::basic_istream<char, std::__1::char_traits<char> > const&, std::__1::basic_istream<char, std::__1::char_traits<char> > const&, std::__1::basic_ostream<char, std::__1::char_traits<char> > const&)", referenced from:
_main in main.cpp.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[3]: *** [src] Error 1
make[2]: *** [CMakeFiles/src.dir/all] Error 2
make[1]: *** [CMakeFiles/src.dir/rule] Error 2
make: *** [src] Error 2
내 CMakeLists.txt 파일은 다음과 같습니다를 내가 cmake 명령을 실행하면
, 내 출력은 이것이다 : 자동 cMAKE에 의해 감지
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sztankatt/Documents/University/PartIII/Project/epiRL/src
기호에 대한 모든 원본 파일을 검색하십시오. 그런 다음 심볼이 포함 된 소스 파일이 컴파일되고 링크되어 있는지 확인하십시오. 또한 기호가 정적 또는 비공개가 아닌지 확인하십시오. –
당신이 제공하는 코드에서'calculateMethylation'의 ** 정의 **가 보이지 않습니다; 'parsing/methylation.h '에이 함수의 * 선언 * 만있다. – Tsyvarev
'calculateMethylationByContext'와 관련된 내용을 보여주고 있지만 오류는'calculateMethylation'과 관련이 있습니다. 이 함수를 어디에서 정의 했습니까? – nos