我无法链接目标文件。编译工作正常,但链接器给我这些错误消息:
testArguments.o:在函数
Z6__mainiPPc': /cygdrive/c/Users/Lukas/work/ProxyServer/src/test/testArguments.cpp:5: undefined reference to
Arguments :: Arguments()' /cygdrive/c/Users/Lukas/work/ProxyServer/src/test/testArguments.cpp:6: 未定义的引用Arguments<int>::insertItem(int)' /cygdrive/c/Users/Lukas/work/ProxyServer/src/test/testArguments.cpp:8: undefined reference to
_ Unwind_Resume'testArguments.o:在函数中ZNSt10_List_baseIiSaIiEED2Ev': /usr/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/bits/stl_list.h:378: undefined reference to
_ Unwind_Resume'testArguments.o:在函数中ZN9__gnu_cxx13new_allocatorISt10_List_nodeIiEE10deallocateEPS2_j': /usr/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/ext/new_allocator.h:110: undefined reference to
运算符delete(void *)' testArguments.o:testArguments.cpp :(。eh_frame + 0x13):undefined 引用__gxx_personality_v0' testArguments.o:testArguments.cpp:(.eh_frame$_ZNSt10_List_baseIiSaIiEED2Ev+0x13): undefined reference to
__ gxx_personality_v0'Makefile:7:食谱for 目标'测试'失败
但是这些函数是在cpp文件中定义的(Argument :: Arguments()Arguments :: insertItem(int)
这是我的头文件:
#ifndef ARGUMENTS_H
#define ARGUMENTS_H
#include <list>
using std::list;
template<class T>
class Arguments{
public:
Arguments(list<T> args);>
Arguments()>;
void insert>Item(T item);
list<T> getValues();
private:
list<T> values;
};
#endif
这里是cpp文件:
#include "include/Arguments.h"
#include <list>
using std::list;
template<class T> Arguments<T>::Arguments(list<T> args) {
values = args;
}
template<class T> Arguments<T>::Arguments() {
}
template<class T> void Arguments<T>::insertItem(T argument){
values.push_back(argument);
}
template<class T> list<T> Arguments<T>::getValues() {
return this.values;
}