Symbol(s) not found for architecture x86_64 - Cmake - Mac sierra

Vor kurzem habe ich begonnen ein neues Projekt in C++. Das problem ist, wenn ich versuche zu kompilieren bekomme ich eine Verknüpfung Fehler. Ich verbrachte den ganzen Tag heute versucht zu Debuggen, aber ich habe nicht wirklich eine gute Lösung zu finden überall. Wenn jemand helfen könnte, es wäre erstaunlich. Ich bin mit einem 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;
}

Benutze ich CLion für meine Programmierung. Wenn ich versuche, es zu bauen, mein cmake-Befehl funktioniert, aber wenn ich dann auf "make" bekomme ich die folgende Fehlermeldung:

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

meine CMakeLists.txt - Datei sieht wie folgt aus:

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})

Wenn ich das cmake Befehl, meine Ausgabe ist diese:

-- 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
Suche nach alle mit den Quelldateien für das symbol ein. Stellen Sie dann sicher, dass die Quell-Datei mit dem symbol kompiliert wird, und verknüpft. Überprüfen Sie auch, dass die Symbole nicht statisch oder privat.
Ich sehe nicht ein, definition der calculateMethylation in dem code, den Sie liefern; es ist nur declaration diese Funktion wird in der parsing/methylation.h.
Zeigen Sie uns Sachen Bezug auf calculateMethylationByContext , aber Ihre Fehler im Zusammenhang mit der calculateMethylation . Wo haben Sie diese Funktion ?

InformationsquelleAutor tomooka | 2016-11-22

Schreibe einen Kommentar