0
嘿人我試圖編譯這個C++程序:鏈接錯誤「LogonUser」編譯C++程序?
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <Windows.h>
#include "Validate.h"
JNIEXPORT jstring JNICALL Java_Validate_takeInfo(JNIEnv *env, jobject obj,
jstring domain, jstring id, jstring idca, jstring password)
{
const char *nt_domain;
const char *nt_id;
const char *nt_idca;
const char *nt_password;
nt_domain = env->GetStringUTFChars(domain, NULL);
nt_id = env->GetStringUTFChars(id, NULL);
nt_idca= env->GetStringUTFChars(idca, NULL);
nt_password = env->GetStringUTFChars(password, NULL);
HANDLE hToken = 0;
char *otherString;
bool aut;
aut = LogonUser(nt_id, nt_domain, nt_password, LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT, &hToken);
if(aut)
{
otherString = "true";
}
else
{
otherString = "false";
}
jstring newString = env->NewStringUTF((const char*)otherString);
return newString;
}
int main()
{
return 0;
}
使用這個命令:
cl -I"c:\Program files\Java\jdk1.5.0_07\include"
-I"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include"
-I"c:\program files\java\jdk1.5.0_07\include\win32"
-LD D:\JNI\%filename%.cpp -D:\JNI\Fe%filename%.dll -link
-LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\lib"
-LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib"
但是我總是得到以下錯誤:
Validate.obj : error LNK2019: unresolved external symbol [email protected]
referenced in function [email protected]
Validate.dll : fatal error LNK1120: 1 unresolved externals
我可能已經嘗試過千種不同的方式來編譯LIBPATH開關。
-link -LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\lib";"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib"
等等。
[更新]如果我周圍的lib路徑切換以及「\ VC \ LIB」前加上「\ PlatformSDK \ LIB」開關我得到這個錯誤:
LINK : fatal error LNK1104: cannot open file 'uuid.lib'
監守現在不能識別其他LIBPATH。任何想法? [/ Update]
我該如何聲明多個libpaths?有什麼其他事情導致這種情況?
一如既往,感謝你們
Advapi32.lib位於我的「C:\ ProgramFiles \ Microsoft Visual Studio 8 \ VC \ PlatformSDK \ Lib」文件夾至極我想包括。我認爲這個問題與我需要聲明多個libpath的事實有關。 – 2009-06-15 18:47:30