I have three header files in my project that describe objects Rational, Complexand RubyObject. The first two are patterns. All can be mutually converted using copy constructors that are defined in the header files, with the exception of those that build Rationalalso Complexfrom const RubyObject&s, which are defined in the source file .
Note: These definitions exist as needed. If all of them are included in the headings, you get a circular dependency .
A back, I ran into some unresolved symbolic errors with two copy constructors defined in the source file. I was able to include the following function in the source file
void nm_init_data() {
nm::RubyObject obj(INT2FIX(1));
nm::Rational32 x(obj);
nm::Rational64 y(obj);
nm::Rational128 z(obj);
volatile nm::Complex64 a(obj);
volatile nm::Complex128 b(obj);
}
and then call nm_init_data()from the entry point to the main file . Moreover, these characters were correctly connected.
Unfortunately, I recently updated GCC and the errors returned. In fact, this looks like a slightly different place with GCC 4.6 (e.g. Travis-CI) .
But this is not a version issue (as I thought before). We see this on the Travis CI Ubuntu system , which launches GCC 4.6. But we do not see it on an Ubuntu machine with GCC 4.8.1 or 4.8.2. But we see this on a Mac OS X machine with 4.8.2 - and not on the same machine with 4.7.2. Disabling optimization also does not help.
nm , undefined:
$ nm tmp/x86_64-darwin13.0.0/nmatrix/2.0.0/nmatrix.bundle |grep RationalIsEC1ERKNS
U __ZN2nm8RationalIsEC1ERKNS_10RubyObjectE
00000000004ca460 D __ZZN2nm8RationalIsEC1ERKNS_10RubyObjectEE18rb_intern_id_cache
00000000004ca458 D __ZZN2nm8RationalIsEC1ERKNS_10RubyObjectEE18rb_intern_id_cache_0
, , undefined, , .
, undefined Rational:
__ZN2nm8RationalIiEC1ERKNS_10RubyObjectE
__ZN2nm8RationalIsEC1ERKNS_10RubyObjectE
__ZN2nm8RationalIxEC1ERKNS_10RubyObjectE
", ", - . "Complex64 Complex128 nm_init_data, - nm -u". volatile Rational, , , , , . . :
void nm_init_data() {
volatile VALUE t = INT2FIX(1);
volatile nm::RubyObject obj(t);
volatile nm::Rational32 x(const_cast<nm::RubyObject&>(obj));
volatile nm::Rational64 y(const_cast<nm::RubyObject&>(obj));
volatile nm::Rational128 z(const_cast<nm::RubyObject&>(obj));
volatile nm::Complex64 a(const_cast<nm::RubyObject&>(obj));
volatile nm::Complex128 b(const_cast<nm::RubyObject&>(obj));
}
, , Complex. Argh!
dyld: lazy symbol binding failed: Symbol not found: __ZN2nm7ComplexIdEC1ERKNS_10RubyObjectE
Referenced from: /Users/jwoods/Projects/nmatrix/lib/nmatrix.bundle
Expected in: flat namespace
dyld: Symbol not found: __ZN2nm7ComplexIdEC1ERKNS_10RubyObjectE
Referenced from: /Users/jwoods/Projects/nmatrix/lib/nmatrix.bundle
Expected in: flat namespace
. , nm_init_data():
namespace nm {
template <typename Type>
Complex<Type>::Complex(const RubyObject& other) {
}
template <typename Type>
Rational<Type>::Rational(const RubyObject& other) {
}
}
: , nm_init_data() (.. ). , .
, ?