I'm trying to use Gdiplus
library in my C++ library
in visual studio 2022
. Before compiling I tested my codes in a c++ code with main function
and it works
. the code is here:
#include <opencv2/opencv.hpp>
#include <Unknwn.h>
#include <windows.h>
#include <ObjIdl.h>
#include <gdiplus.h>
#include <iostream>
#include <vector>
using namespace Gdiplus;
#pragma comment( lib, "gdiplus.lib" )
cv::Mat to_mat(Gdiplus::Bitmap& image)
{ // my codes }
HRESULT GetGdiplusEncoderClsid(const std::wstring& format, GUID* pGuid)
{ // my codes }
int main()
{ // my codes }
But when I tried to use it in my library, I faced with lots of errors. I searched a lot and now I'm suspicious of order of order of #includes or namespace collision
. Here is my library header (.h)
:
#pragma once
#pragma warning(disable : 4996)
#include <opencv2\core.hpp>
#include <INIReader.h>
#include <iostream>
#include <algorithm>
#include <filesystem>
#include <math.h>
#include <chrono>
#include <numeric>
#include <Unknwn.h>
#include <windows.h>
#include <ObjIdl.h>
#include <gdiplus.h>
#include <vector>
using namespace Gdiplus;
#pragma comment( lib, "gdiplus.lib" )
namespace utl
{ // bunch of free function codes }
and here is .cpp
codes of my library:
#include "pch.h"
#define getCurrentDir _getcwd
#pragma warning(disable : 4996)
#include "Util.h"
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
#include <direct.h>
#include <libloaderapi.h>
#include <numeric>
#include <functional>
#include <fstream>
#include <math.h>
#include <string>
#include <time.h>
#include <format>
#include <corecrt_math_defines.h>
#include <codecvt>
#include <Unknwn.h>
#include <windows.h>
#include <ObjIdl.h>
#include <gdiplus.h>
using namespace std;
using std::vector;
using std::string;
using namespace cv;
using namespace Gdiplus;
#pragma comment( lib, "gdiplus.lib" )
and here is several of errors in visual studio:
almost all of the errors are caused by std::max
and std::min
in different place any used library. here is an example of the errors:
How can I fix it? and why does it happen it me?