由于一些奇怪的原因,当我尝试编译时,我得到错误代码LNK2019与此描述:
严重级代码描述项目文件行抑制状态 错误LNK2019未解析的外部符号__imp__PathCombineW @ 12在函数" void __cdecl createEnvironment中引用(wchar_t *,struct _SECURITY_ATTRIBUTES *,struct _SECURITY_ATTRIBUTES *)" (?createEnvironment @@ YAXPA_WPAU_SECURITY_ATTRIBUTES @@ 1 @ Z)Umberella F:\ Projects \ Umberella \ Umberella \ main.obj 1
#include <iostream>
#include <windows.h>
#include "Shlwapi.h"
using namespace std;
void createEnvironment (wchar_t* lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes, LPSECURITY_ATTRIBUTES lpSecurityAttributesRest)
{
//Create the main directory
CreateDirectory(lpPathName, lpSecurityAttributes);
//Combine main with subfolder and put it in buffer loggdir
wchar_t* tempERRLoggDir = L"//Reportlogg";
wchar_t loggERRdir[MAX_PATH];
PathCombine(loggERRdir, lpPathName, tempERRLoggDir);
CreateDirectory(loggERRdir, lpSecurityAttributesRest);
return;
}
void main (void)
{
//Define main directory
wchar_t* mainDir = L"C://Umberella";
createEnvironment(mainDir, NULL, NULL);
}
答案 0 :(得分:0)
这不是编译器错误,而是链接器错误。您缺少定义PathCombine
的库。
在#include
标题后添加:
#pragma comment (lib, "shlwapi")
这将链接到满足链接器所需的shlwapi.lib
文件。