OpenImageIO
OpenImageIO copied to clipboard
include error with fmt lib
Describe the bug I include the fmt library header before the OpenImageIO and get the compiler error.
#include <fmt/format.h>
#include <OpenImageIO/imagebuf.h>
Detailed compilation errors
/usr/include/OpenImageIO/fmt/ostream.h:22:3: error: ‘buffer’ does not name a type
22 | buffer<Char>& buffer_;
| ^~~~~~
/usr/include/OpenImageIO/fmt/ostream.h:25:19: error: expected ‘)’ before ‘<’ token
25 | formatbuf(buffer<Char>& buf) : buffer_(buf) {}
| ~ ^
| )
/usr/include/OpenImageIO/fmt/ostream.h:35:53: error: expected ‘;’ at end of member declaration
35 | int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
| ^
| ;
/usr/include/OpenImageIO/fmt/ostream.h:35:55: error: ‘FMT_OVERRIDE’ does not name a type; did you mean ‘FMT_VERSION’?
35 | int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
| ^~~~~~~~~~~~
| FMT_VERSION
/usr/include/OpenImageIO/fmt/ostream.h:41:62: error: expected ‘;’ at end of member declaration
41 | std::streamsize xsputn(const Char* s, std::streamsize count) FMT_OVERRIDE {
| ^
| ;
/usr/include/OpenImageIO/fmt/ostream.h:41:64: error: ‘FMT_OVERRIDE’ does not name a type; did you mean ‘FMT_VERSION’?
41 | std::streamsize xsputn(const Char* s, std::streamsize count) FMT_OVERRIDE {
| ^~~~~~~~~~~~
| FMT_VERSION
Presumably there's another fmt already installed on your system. Do you know what version of fmt that is? And which version is in OIIO?
For that matter, which version of OIIO are you using? OS?
@lgritz I utilze the ubunut20.04 system and insatll OIIO through sudo apt-get install openimageio-tools. This is really caused by multiple fmt versions in the system after debug. I have installed version 9.10 fmt.I checked cmake and found that OIIO will copy fmt to the installation file. A simple solution is to directly replace fmt in OIIO with the version in the system. I suggest using fmt in the system instead of always copying through the compilation option。
Is this still an issue?
@lgritz After debug, I can provided some useful information about this situation. OpenImageIO will be copied to the fmt headers into installation directory such as details/fmt after perform install, This means that in my system, there are two files with fmt header files. When I need to use the fmt library in other libraries, such as spdlog, this results in two different header file locations appearing simultaneously. This caused an error, currently I have to specify that spdlog uses its bound fmt by defining relevant macros instead of the current system version to avoid this error.