【问题标题】:CImg library when compiling return undefined reference to `__imp_SetDIBitsToDevice'CImg 库编译时返回未定义的引用 `__imp_SetDIBitsToDevice'
【发布时间】: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
  • 好的,很酷。我会把它写成答案让其他人很容易看到。

标签: c++ cimg


【解决方案1】:

我认为您需要在 Windows 上链接到 GDI32。比如:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2021-05-17
    • 2012-08-16
    • 2023-03-10
    • 1970-01-01
    • 2019-09-05
    • 2013-10-22
    相关资源
    最近更新 更多