使用OpenMS命名空间时出现未定义的符号问题

时间:2010-11-07 21:33:40

标签: c++ compiler-construction compiler-errors

我正在尝试使用一些示例代码与OpenMS愉快地工作并遇到很多麻烦。我有(只是一个小样本程序,作为一个例子):

#include <OpenMS/FILTERING/SMOOTHING/GaussFilter.h>
#include <OpenMS/FORMAT/MzMLFile.h>
#include <OpenMS/KERNEL/StandardTypes.h>
#include <stdio.h>

using namespace OpenMS;
using namespace std;

Int main(){
  PeakMap exp;

  MzMLFile mzdata_file;
  mzdata_file.load("../sampledata_Centroidmode.mzML",exp);

  GaussFilter g;
  Param param;
  param.setValue("gaussian_width",1.0);
  g.setParameters(param);

  g.filterExperiment(exp);

  return 0;
}

我编译它:

g++ -Wall -IOpenMS-1.7.0/include -IOpenMS-1.7.0/contrib/include -I/Library/Frameworks/QtCore.framework/Headers -arch i386 scratch.cpp

它出现了一大堆错误(实际上约为500Kb)。问题似乎在于“使用命名空间OpenMS;”一小部分错误:

Undefined symbols:
  "OpenMS::DataValue::DataValue(int)", referenced from:
      OpenMS::Internal::MzMLHandler<OpenMS::MSExperiment<OpenMS::Peak1D, OpenMS::ChromatogramPeak> >::handleUserParam_(OpenMS::String const&, OpenMS::String const&, OpenMS::String const&, OpenMS::String const&, OpenMS::String const&)in cc7cSzjW.o
  "OpenMS::DataValue::DataValue()", referenced from:
      OpenMS::Internal::MzMLHandler<OpenMS::MSExperiment<OpenMS::Peak1D, OpenMS::ChromatogramPeak> >::handleUserParam_(OpenMS::String const&, OpenMS::String const&, OpenMS::String const&, OpenMS::String const&, OpenMS::String const&)in cc7cSzjW.o
  "OpenMS::SourceFile::operator!=(OpenMS::SourceFile const&) const", referenced from:
      OpenMS::Internal::MzMLHandler<OpenMS::MSExperiment<OpenMS::Peak1D, OpenMS::ChromatogramPeak> >::writeTo(std::basic_ostream<char, std::char_traits<char> >&)in cc7cSzjW.o
      OpenMS::Internal::MzMLHandler<OpenMS::MSExperiment<OpenMS::Peak1D, OpenMS::ChromatogramPeak> >::writeTo(std::basic_ostream<char, std::char_traits<char> >&)in cc7cSzjW.o
      OpenMS::Internal::MzMLHandler<OpenMS::MSExperiment<OpenMS::Peak1D, OpenMS::ChromatogramPeak> >::writeTo(std::basic_ostream<char, std::char_traits<char> >&)in cc7cSzjW.o

...

ld: symbol(s) not found
collect2: ld returned 1 exit status

有没有人能够了解我做得不对?

1 个答案:

答案 0 :(得分:1)

尝试将其编译为目标文件( - c),然后查看问题是否仍然存在。 E..g。:这是编译问题还是链接问题

另外:是否应该有 -L 标志来搜索特定的库路径?是否应该在特定中链接 -l <​​/ strong>标志?