0

I have just started learning programming, and I am facing troubles adding libraries ( Other than STD libraries) in my programs. I use codeblocks IDE and I wanted to add a library CImg from the internet.

After reading many threads I have done the following steps however I still get an error loading one of the examples provided CImg people

  1. Downloaded Cimg folder which has a Cimg.h file along with other example files.
  2. Unzip the folder to E drive.
  3. open code blocks>compiler settings(gnu gcc compiler)>search libraries
  4. under search libraries I have compiler tab and linker tab where I have added the path of the downloaded folder.
  5. next when I open an example provided by the developer, build and run it.

The cimg.h file open up and I get the following error:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'int cimg_library::cimg::fseek(FILE*, INT_PTR, int)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5617|error: '_fseeki64' was not declared in this scope|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h||In function 'INT_PTR cimg_library::cimg::ftell(FILE*)':|
E:\programming\cpp programming\CImg-2.0.0_pre012317\CImg.h|5626|error: '_ftelli64' was not declared in this scope|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 10 second(s)) ===|

Please help me out, Also kindly explain to me what I am doing as I have no idea.

EDIT: As pointed out to me in the comments I have changed my compiler to TDM-GCC MinGW 64 bit compiler. But now I get a different type of error, is it because I havent installed the compiler properly because I can run hello world using this compiler. the error that i get is :

||=== Build: Debug in hello (compiler: GNU GCC Compiler) ===| obj\Debug\main.o||In function cimg_library::CImgDisplay::paint()':| E:\programming\cpp programming\hello\..\CImg-2.0.0_pre012317\CImg.h|9696|undefined reference to__imp_SetDIBitsToDevice'| ||error: ld returned 1 exit status| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

1 Answers1

0

Finally I have found out what were my mistakes and how to correct them.

  1. I was using a 32 bit compiler, So I switched to one for 64 bits.
  2. After that I had not linked gdi32 library. So when I went to linker settings and added gdi32 to linked libraries evrything started to work.

Thank you for helping me out.