c++cimg

C++ CImg Library Error C2665 What is the problem?


cimg error

Error code:

Severity Code Description Project File Line Suppression State Error C2665 'cimg_library::cimg::rand': none of the 4 overloads could convert all the argument types goruntuisleme C:\Users\sasniac\source\repos\goruntuisleme\goruntuisleme\CImg.h 25469

Code:

#include <iostream>
#include "CImg.h"

using namespace cimg_library;

int main()
{
 std::cout << "Hello World!\n";
}

Solution

  • I tested the library for you. It works after some modifications.

    1. I suppose you downloaded the library from the official site (here)

    2. Some cast to (cimg_uint64 *) are missing in the following functions:

     static double mp_u(_cimg_math_parser& mp) {
            return cimg::rand(_mp_arg(2),_mp_arg(3),(cimg_uint64 *) &mp.rng);
     }    
    

    Here:

    static double mp_srand0(_cimg_math_parser& mp) {
            cimg::srand((cimg_uint64 *) &mp.rng);  
    //...
    }  
    

    Here :

     static double mp_g(_cimg_math_parser& mp) {
        cimg::unused(mp);
        return cimg::grand((cimg_uint64 *) &mp.rng);
     }