mardi 31 octobre 2017

C++ struct template not found for architecture x86_64

test.h

struct Test {
    template <typename T>
    static const T test(T a, T b);
};

test.cpp

#include "test.h"

template <typename T>
const T Test::test(T a, T b){
   return a + b;
}

main.cpp

#include "test.h"
#include <iostream>

void main(){
   int a = 3, b = 5; 
   std::cout << Test::test(a, b) << std::endl;
}

clang++ -std=c++11 ./test.cpp ./main.cpp -o ./test

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Aucun commentaire:

Enregistrer un commentaire