简体   繁体   English

Windows C ++ Ldap构建错误_imp__ldap_init()

[英]windows C++ Ldap build error _imp__ldap_init()

I am building a C++ program that queries against Active Directory using (Apache Directory studio) LDAP . 我正在构建一个使用(Apache Directory studio)LDAP对Active Directory进行查询的C ++程序。 Iam doing it with codeblocks IDE and windows 10. I have the following code sample from the program: 我用Codeblocks IDE和Windows 10来做。我从程序中得到以下代码示例:

#include<iostream>
#include<windows.h>
#include<winldap.h>

using namespace std;

int main() {

    LDAP* testLdapConnection = NULL;
    ULONG version = LDAP_VERSION1;
    ULONG connectionSuccess = 0;
    testLdapConnection = ldap_initA("localhost",389);
    if(testLdapConnection==NULL){
        cout<<"connection Failed";
    }
    else{
        cout<<"Success";
    }

}

When I try to build this sample in codeblocks, the build fails and the line with ldap_init() is underlined in red. 当我尝试在代码块中构建此示例时,构建失败,并且带有ldap_init()的行用红色下划线标出。 When I hover the mouse over the error, it says "Undefined reference to _imp__ldap_initA()." 当我将鼠标悬停在错误上时,它说“对_imp__ldap_initA()的未定义引用”。

您必须将Wldap32.lib添加到项目中的链接库列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM