Hacking C++ on non windows platform isn’t always as comfortable as it used to be. Having a new component in the making for Icinga2, I had defined function prototypes in the HostsTable class, but was missing their implementation. On windows, the dlopen loader would spit a missing symbols warning in my face, on linux/unix it does not provide a telling error return code and message, which is why the component loader fails to create an instance of the new component object afterwards. While it *should* provide a yet more telling error message on the final release, during development cycles it’s just mandatory that you get to know your code and errors. Which is why I put it here, having all valuable information on my blog.

The error

[2013/07/05 09:30:39 +0200]  debug/config: Adding item to compiler context: type=CompatLog; name=compat-log
[2013/07/05 09:30:39 +0200]  information/base: Loading library 'liblivestatus.la'
[2013/07/05 09:30:39 +0200]  critical/icinga-app: Config error: configitembuilder.cpp(104): Throw in function icinga::ConfigItem::Ptr icinga::ConfigItemBuilder::Compile()
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >
std::exception::what: The type 'LivestatusComponent' is unknown: in tools/configconvert/test.conf: 34:1-34:1
[icinga::StackTrace*] =
Stacktrace:

[Inferior 1 (process 29025) exited with code 01]
(gdb)

The missing symbols

$ cd ~/i2
$ ld -o keks sbin/icinga2 lib/icinga2/*.so
ld: error in sbin/icinga2(.eh_frame); no .eh_frame_hdr table will be created.
lib/icinga2/liblivestatus.so: undefined reference to `livestatus::HostsTable::InitialStateAccessor(boost::shared_ptr const&)'
lib/icinga2/liblivestatus.so: undefined reference to `livestatus::HostsTable::IconImageExpandedAccessor(boost::shared_ptr const&)'
lib/icinga2/liblivestatus.so: undefined reference to `livestatus::HostsTable::DowntimesAccessor(boost::shared_ptr const&)'

The fix

https://git.icinga.org/?p=icinga2.git;a=commit;h=e448374674f439808924695dec4ef82f79f891d0

%d bloggers like this: