Travis-CI在符号查找错误时失败,在其他地方工作正常

时间:2013-09-27 16:13:48

标签: c++ gcc travis-ci gcc4.6

我有一个名为NMatrix的库(技术上是一个Ruby扩展),它是用C和C ++编写的。它使用C ++模板来管理不同类型,例如Rational128Rational64。它还有RubyObjectComplex64以及Complex128。我强制这些模板版本是通过在一个目标文件中创建一些来构建的 - 在一个从库入口点调用的函数中。

在GCC 4.7中运行得很好,但是when I compile on Travis-CI, it encounters an undefined symbol error at run-time

exposes cblas rot /home/travis/.rvm/rubies/ruby-2.0.0-p247/bin/ruby: symbol lookup error: /home/travis/build/SciRuby/nmatrix/lib/nmatrix.so: undefined symbol: _ZN2nm7ComplexIfEC1ERKNS_10RubyObjectE

未定义的符号是nm::Complex::Complex(nm::RubyObject const&),它是明确定义和实例化的(见下文)。

这是data.cpp的简化版本:

#include "data.h"

void nm_init_data() { // called from library entry point
  // These force the compiler to build these versions of the typedef'd templates.
  // I think this is a gross way to do it, but can't find a better idea.
  nm::RubyObject obj(INT2FIX(1));
  nm::Rational32 x(obj);
  nm::Rational64 y(obj);
  nm::Rational128 z(obj);
  nm::Complex64 a(obj);    // Clear instantiation of the undefined symbol
  nm::Complex128 b(obj);
}

data.h喜欢这样:

#include "nmatrix.h"

#include "complex.h" // classes are all declared in headers
#include "rational.h"
#include "ruby_object.h"

void nm_init_data();

nmatrix.cpp是声明库入口点的位置。相关部分如下所示:

void Init_nmatrix() {
  // declarations of Ruby-exposed functions here, e.g., 
  rb_define_method(cNMatrix, "initialize", (METHOD)nmatrix_constructor, -1);

  nm_init_data();
}

那么我做错了什么?为什么这适用于GCC 4.7.1(所有规格都通过),而不是4.6.3?这是一个错误吗? (如果这是一个错误,是否有解决办法?)

如果您感到好奇,相关文件的完整版本为here

0 个答案:

没有答案
相关问题