[英]WinAPI Linking c++
Win7 64bit Qt5.4.1 -> MinGW 4.9.1 32bit Win7 64位Qt5.4.1-> MinGW 4.9.1 32位
Below is a simple Qt app that generates unique GUID: 以下是一个生成独特GUID的简单Qt应用程序:
guid.pro guid.pro
QT += core
QT -= gui
TARGET = qt-msync
CONFIG += console
CONFIG -= app_bundle
#INCLUDEPATH += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Include"
LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib/Rpcrt4.lib"
TEMPLATE = app
SOURCES += main.cpp
main.cpp main.cpp
#include <QCoreApplication>
#include <Rpc.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
GUID myGuid;
CoCreateGuid(&myGuid);
return a.exec();
}
If the qmake contains INCLUDEPATH += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Include" I am struck with 72 errors all of which look like errors related to double underscore macros. 如果qmake包含INCLUDEPATH + =“ C:/ Program Files / Microsoft SDKs / Windows / v7.1 / Include”,我将被发现72条错误,所有这些错误看起来都与双下划线宏相关。
As it stands \\main.cpp:9: error: undefined reference to `_imp__CoCreateGuid@4' Obviously a linker error but library file is present LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib/Rpcrt4.lib" 按现状显示\\ main.cpp:9:错误:对_imp__CoCreateGuid @ 4的未定义引用显然是链接器错误,但存在库文件LIBS + =“ C:/ Program Files / Microsoft SDKs / Windows / v7.1 / Lib / Rpcrt4.lib”
Anyone else managed to get Rpc.h to cooperate compiling a 32 target on 64 Machine ? 其他人设法使Rpc.h合作在64 Machine上编译32目标吗?
I have also tried simpler CMake C++ only code compiling with MSVC (the one included in the Windows SDK) and it throws the same error. 我还尝试了使用MSVC(Windows SDK中包含的代码)进行更简单的CMake C ++代码编译,并且抛出相同的错误。
#INCLUDEPATH += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Include"
#LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib/Rpcrt4.lib"
win32
{
LIBS += -lole32
}
I was able to build exactly your code using only ole32.lib. 我仅使用ole32.lib就可以构建您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.