【发布时间】:2020-07-11 11:25:28
【问题描述】:
我在安装了 MinGW 编译器的 Windows 10 上使用 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
CImg.h 文件位于 tutorial.cpp 文件夹中。这是我用来编译的命令:
g++ tutorial.cpp -o tutorial.exe
这是我第一次使用 C++ 中的库,CImg 看起来相当容易使用,但如果您使用其他库编辑照片,请告诉我。
提前致谢!
【问题讨论】:
-
我不会说 Windows,但我认为您需要链接到 Windows 上的 GDI32。类似
g++ ... -lgdi32 -
好的,很酷。我会把它写成答案让其他人很容易看到。