gpt4 book ai didi

c++ - 未定义对 CreateCompatibleDC、BitBlt 等的引用?

转载 作者:行者123 更新时间:2023-11-30 02:50:05 26 4
gpt4 key购买 nike

我已经链接到 gdi32.lib。无奈之下,我还链接了两个不同版本的 gdi32.lib 以及 gdiplus.lib,并包含了我能找到的所有 gdi 头文件,但无济于事。然而,这个问题在额外链接之前就开始了,所以我想我可以放心地假设我的问题不是库之间的冲突或任何类似的干扰。

包含/定义:

#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#include <iostream>
#include <process.h>
#include <windows.h>
#include <winuser.h>
#include <gdiplus.h>
#include "UVMap.h"

相关代码:

case WM_PAINT:{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMemory = CreateCompatibleDC(hdc);
BITMAP bmp = screen.getBitmap(hdcMemory);
BitBlt(hdc,0,0,w,h,hdcMemory,0,0,SRCCOPY);
EndPaint(hwnd,&ps);
DeleteDC(hdc);
}break;

我在搜索此问题时发现的每个结果都声称您只需链接到 gdi32。以下是我添加的链接:

  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\Gdi32.Lib
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\Gdi32.Lib
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\GdiPlus.lib

编辑:错误显示如下:

.../Testing.cpp:50: undefined reference to `CreateCompatibleDC@4'
.../Testing.cpp:52: undefined reference to `BitBlt@36'

像那样?我通过 Project > Properties > Path Variables 在 Eclipse 中进行了链接。 “链接的资源”选项卡下没有任何条目,也不显示为可编辑。

最佳答案

您需要链接到 coredll.lib for CreateCompatibleDC .

您需要链接到 Gdi32.lib for BitBlt .

作为引用,当您收到涉及 Windows 函数的链接错误时,只需谷歌该函数并转到该函数的 MSDN 文档(我已链接到这两个特定函数的两个页面),然后向下滚动到要求部分,并确保您链接到指定的库。

关于c++ - 未定义对 CreateCompatibleDC、BitBlt 等的引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20724278/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com