提问者:小点点

编译时的CImg库返回对`__IMP_SetDibitstODevice'的未定义引用


我在安装了MinGW编译器的Windows10上使用VSCode。 我曾尝试使用CImg库编辑图像(http://CImg.eu/),当我尝试从教程(http://CImg.eu/reference/group__cimg__tutorial.html)编译代码时,我遇到了以下错误:

C:\Users\Martini\AppData\Local\Temp\ccBswQ5w.o:tutorial.cpp:(.text$_ZN12cimg_library11CImgDisplay5paintEv[_ZN12cimg_library11CImgDisplay5paintEv]+0xba): undefined reference to `__imp_SetDIBitsToDevice'
collect2.exe: error: ld returned 1 exit status

我在tutorial.cpp文件夹中有cimg.h文件。 下面是我用来编译的命令:

g++ tutorial.cpp -o tutorial.exe

这是我第一次使用C++中的库,CImg看起来相当容易使用,但是如果您使用过其他库来编辑照片,请告诉我。

提前谢谢!


共1个答案

匿名用户

我想你需要链接到Windows上的GDI32。 类似于:

g++ tutorial.cpp -lgdi32 -o tutorial.exe