以qt5.5 msvc2013 32位版例:
1、当然是.pro文件中添加相应的头文件和库了:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -llibuv
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -llibuv
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include
2、修改如下qt安装目录Qt\Qt5.5.0msvc2013x86\5.5\msvc2013\mkspecs\common下msvc-desktop.conf找到QMAKE_LFLAGS_DEBUG配置项,在后面添加/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib,修改前:
QMAKE_LFLAGS_DEBUG = /DEBUG
修改后:
QMAKE_LFLAGS_DEBUG = /DEBUG /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib
3、在实现文件中包含一下依赖库:
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "IPHLPAPI.lib")
#pragma comment(lib, "Psapi.lib")
#pragma comment(lib, "advapi32.lib")
通过这三步编译就不会出错了