lundi 22 juin 2020

Compilation issue with std::min and std::max using CImg library

I am currently trying to implement the cimg library in a project also using fftw, libtiff, Jsoncpp and openMP libraries. Every library has been added to the .pro with the right path. I am making this project on QtCreator, using MacOS High Sierra 10.13.6 version.

Here is a copy of the .pro file :

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp \

HEADERS += \
    cimg.h \

INCLUDEPATH += /usr/include
INCLUDEPATH += /opt/X11/include
INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/Cellar/jsoncpp/1.9.3/include
INCLUDEPATH += /usr/local/Cellar/libtiff/4.1.0/include
INCLUDEPATH += /usr/local/Cellar/libomp/10.0.0/include

DEPENDPATH += /usr/include

LIBS += -L/usr/lib -lpthread -lm -ldl
LIBS += -L/opt/X11/lib -lX11
LIBS += /usr/local/lib/libfftw3.a
LIBS += -L/usr/local/Cellar/jsoncpp/1.9.3/lib -ljsoncpp
LIBS += -L/usr/local/Cellar/libtiff/4.1.0/lib -ltiff
LIBS += -L/usr/local/Cellar/libomp/10.0.0/lib -lomp


QMAKE_CXXFLAGS += -Xpreprocessor -fopenmp -O4 -J8

DISTFILES += \
    config.json
 copydata.commands = $(COPY_DIR) $$PWD/config.json $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata

However, when I try to compile, the CImg header returns lots of errors every time std::min or std::max is called, that is to say a thousand times, with the following error missage :

error : no member named 'max' in namespace 'std'
error : no member named 'min' in namespace 'std'

I think there might be a conflict between math and Cimg libraries, as those lines in the Cimg code let me think :

// Check if min/max/PI macros are defined.
//
// CImg does not compile if macros 'min', 'max' or 'PI' are defined,
// because it redefines functions min(), max() and const variable PI in the cimg:: namespace.
// so it '#undef' these macros if necessary, and restore them to reasonable
// values at the end of this file.
#ifdef min
#undef min
#define _cimg_redefine_min
#endif
#ifdef max
#undef max
#define _cimg_redefine_max
#endif
#ifdef PI
#undef PI
#define _cimg_redefine_PI
#endif

However, I still have not been able to solve this issue, and that is why I ask you what could be the source of it..

Aucun commentaire:

Enregistrer un commentaire