How to draw a simple function using the CImg library?

1.8k Views Asked by At

I am looking forward to draw some simple mathematical functions (like y = x^3) using the CImg library.

I tried to use it but it is always giving me the following error:
undefined reference to `SetDIBitsToDevice@48'.

Anyone here can help me in providing a very simple example of drawing curves or mathematical functions using this library? (or maybe plotting some points in certain mathematical graph).

Note: The CImg Library is an open source, C++ toolkit for image processing.

If the CImg library is incapable of drawing functions, then maybe you can provide me with a step-by-step small tutorial of how to do that with some other C++ libraries.

Thanks in advance for your help!

1

There are 1 best solutions below

0
On

Hans is right, you need to link your code with the gdi32.lib library, a Windows-specific library that handles the drawing of graphic primitives on your screen. CImg uses it to display images on the screen. You will need gdi32 for almost all tasks you want to do with CImg (and other libraries as well), so this is a good idea to learn how to do this (linking your code with an external library is quite common and out of topic for this thread).