You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CMakeFiles/my_project.dir/src/RuntimeFileLogger.cpp.o: In function `void __gnu_cxx::new_allocator<spdlog::sinks::daily_file_sink<std::mutex, custom_file_name_calculator> >::construct<spdlog::sinks::daily_file_sink<std::mutex, custom_file_name_calculator>, std::string&, int, int>(spdlog::sinks::daily_file_sink<std::mutex, custom_file_name_calculator>*, std::string&, int&&, int&&)':
/usr/include/c++/5/ext/new_allocator.h:120: undefined reference to `std::function<void (std::string const&, _IO_FILE*)>::function()'
/usr/include/c++/5/ext/new_allocator.h:120: undefined reference to `std::function<void (std::string const&, _IO_FILE*)>::function()'
collect2: error: ld returned 1 exit status
Note that I'm not specifying every parameter for the daily_file_sink constructor, but relying on the default values specified here:
daily_file_sink(filename_t base_filename, int rotation_hour, int rotation_minute, bool truncate = false, uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
The problem seems to come from the fact that in places like file_helper::open(), we have code like this:
if (event_handlers_.before_open)
{
event_handlers_.before_open(filename_);
}
So although the before_open() call would never be made when using the default event_handlers = {}, the linker is still looking for the symbol which simply does not exist.
I worked around this by changing my code to be this:
I have no idea why I was getting the undefined reference errors for after_open() and before_close(), but not for before_open() and after_close(). Something to do with having two parameters instead of one?
One possible fix would be to change the defaulted value for the constructor:
I have the following code to create a daily_file_sink with an overridden calc_filename():
When this is linked, I get the following errors:
Note that I'm not specifying every parameter for the daily_file_sink constructor, but relying on the default values specified here:
The problem seems to come from the fact that in places like file_helper::open(), we have code like this:
So although the before_open() call would never be made when using the default
event_handlers = {}
, the linker is still looking for the symbol which simply does not exist.I worked around this by changing my code to be this:
I have no idea why I was getting the undefined reference errors for after_open() and before_close(), but not for before_open() and after_close(). Something to do with having two parameters instead of one?
One possible fix would be to change the defaulted value for the constructor:
The text was updated successfully, but these errors were encountered: