C ++头文件编译错误?

时间:2013-06-17 05:00:41

标签: c++ compiler-errors header-files

您好我正在将此函数写入我的help.h文件中。

这是我的help.h文件

#ifndef help_H
#define help_H

#include <iostream>
#include <string>
#include <tr1/array>

class help {

    public:
    template<std::size_t N>
    static std::string to_string( std::tr1::array<char, N> const& arr);

};

#endif

这是我的.cpp文件

#include "help.h"

template<std::size_t N>
std::string help::to_string( std::tr1::array<char, N> const& arr)
{
    const char* str = reinterpret_cast<const char*>(arr.data());
    return std::string( str, str+N );
}

我想知道哪一部分是错的? 当我编译时,它说:

mpic++ -o local help.cpp globalVar.cpp Graphnode.cpp move.cpp ioCheckFile.cpp mySearch.cpp ods_v3.cpp -L/opt/local/lib/  -lboost_iostreams-mt -lz -I/opt/local/include
Undefined symbols for architecture x86_64:
  "std::string help::to_string<16ul>(std::tr1::array<char, 16ul> const&)", referenced from:
      mySearch::bfs(Graphnode, std::tr1::array<char, 16ul>, char, std::queue<Graphnode, std::deque<Graphnode, std::allocator<Graphnode> > >&) in mySearch-ekZOo8.o
      mySearch::dfs(Graphnode, std::tr1::array<char, 16ul>, char, std::queue<Graphnode, std::deque<Graphnode, std::allocator<Graphnode> > >, std::queue<Graphnode, std::deque<Graphnode, std::allocator<Graphnode> > >, std::tr1::array<std::tr1::unordered_map<std::string, char, std::tr1::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, char> >, false>, 2000ul>) in mySearch-ekZOo8.o
      _main in ods_v3-580g0A.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: *** [local] Error 1

0 个答案:

没有答案