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

问题描述 投票:0回答:1

我正在尝试获取一些示例代码,以便与 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

有人知道我做错了什么吗?

c++ compiler-errors
1个回答
1
投票

尝试将其编译为目标文件(-c),看看问题是否仍然出现。 例如:这是编译问题还是链接问题

另外:是否应该有一个 -L 标志来搜索特定的 库路径? 是否应该有一个 -l 标志来链接到特定的

© www.soinside.com 2019 - 2024. All rights reserved.