I am trying to use native windows API with Qt using mingw toolset. There are link problems with some functions. What happens? Is this a bug with mingw name mangling?
#ifdef Q_WS_WIN HWND hwnd = QWidget::winId(); HDC hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL ) ; Rectangle(hdcEMF,100,100,200,200); HENHMETAFILE hemf = CloseEnhMetaFile(hdcEMF); OpenClipboard(hwnd); EmptyClipboard(); SetClipboardData(CF_ENHMETAFILE,hemf); CloseClipboard(); #else
The errors:
undefined reference to `CreateEnhMetaFileW@16′
undefined reference to `Rectangle@20′
undefined reference to `CloseEnhMetaFile@4′
The functions
CreateEnhMetaFileW()andCloseEnhMetaFile()are defined in the static library Gdi32.lib, so you have to make sure to link against that. Try adding-lgdi32to the end of your command line you’re using to compile. If that doesn’t work, you might have to specify the full path to Gdi32.lib by adding-L/path/to/folder/containing/the/library -lgdi32instead.