使用Chemfiles库读取轨迹文件时出错

时间:2018-10-03 20:08:51

标签: c++ cmake g++

我需要编写一段cpp代码来读取轨迹文件(.pdb或.dcd文件)。我已按照chemfiles库主页上的步骤读取文件。我收到有关架构x86_64的未定义符号的错误(请参阅下面的错误日志)。

我想要的是:可以使用chemfiles库(或任何其他合适的库)读取.dcd / .pdb文件-我需要访问文件中列出的原子的坐标。

使用以下命令编译时会重现错误的代码:

#include "/usr/local/include/chemfiles.hpp" //path to library on my mac

int main(int argc, char *argv[]) {
    chemfiles::Trajectory testfile("test.dcd");
    return 1;
}

使用以下命令在CLI中成功编译的代码:

#include "/usr/local/include/chemfiles.hpp" //path to library on my mac

int main(int argc, char *argv[]) {
    // chemfiles::Trajectory testfile("test.dcd");
    return 1;
}

编译程序的命令:

g++-8 -fopenmp trial.cpp -o trial -lchemfiles -L /usr/local/lib
// I am using openmp because my original code is about parallelisation with openmp

错误:

Undefined symbols for architecture x86_64:
  "chemfiles::Trajectory::Trajectory(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, char, 
std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&)", referenced from:
  _main in ccnk7agz.o
  "std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> >::find(char, unsigned long) const", 
referenced from:
      file_open_info::parse(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> > const&, 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const&) in libchemfiles.a(Trajectory.cpp.o)
      split_comment(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> >&) in 
libchemfiles.a(LAMMPSData.cpp.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> >::rfind(char, unsigned long) const", 
referenced from:
      file_open_info::parse(std::__1::basic_string<char,  
std::__1::char_traits<char>, std::__1::allocator<char> > const&, 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const&) in libchemfiles.a(Trajectory.cpp.o)
      chemfiles::SDFFormat::read(chemfiles::Frame&) in 
libchemfiles.a(SDF.cpp.o)
  "std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> >::compare(unsigned long, unsigned long, char 
const*, unsigned long) const", referenced from:
      file_open_info::parse(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> > const&, 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const&) in libchemfiles.a(Trajectory.cpp.o)
      chemfiles::Trajectory::Trajectory(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> >, char, 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const&) in libchemfiles.a(Trajectory.cpp.o)
      chemfiles::FormatFactory::register_format(chemfiles::FormatInfo, 
std::__1::function<std::__1::unique_ptr<chemfiles::Format, 
std::__1::default_delete<chemfiles::Format> > 
(std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> >, chemfiles::File::Mode, 
chemfiles::File::Compression)>) in libchemfiles.a(FormatFactory.cpp.o)
      chemfiles::Frame::guess_bonds()     in 
libchemfiles.a(Frame.cpp.o)
      chemfiles::FormatInfo::FormatInfo(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> >) in 
libchemfiles.a(CSSR.cpp.o)
      chemfiles::FormatInfo::FormatInfo(std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> >) in 
libchemfiles.a(MMTF.cpp.o)
      chemfiles::MOL2Format::read(chemfiles::Frame&) in 
libchemfiles.a(MOL2.cpp.o)
      ...

0 个答案:

没有答案