yourWaifu / sleepy-discord

C++ library for the Discord chat client. Please use Rust for new bots
https://yourWaifu.github.io/sleepy-discord/
MIT License
707 stars 95 forks source link

libcurl_a.lib(ldap.obj) Error: LNK4098, LNK2019, LNK1120 #82

Closed Tomentos closed 6 years ago

Tomentos commented 6 years ago

So I used setup.py to compile install the library and compiled curl manually. I linked everything in the propertys of the project but somehow I always get these errors. I already tried to change the "VC" version when I compiled curl with "nmake" but with every version I get the same error. I also added "CURL_STATICLIB" in the "Preprocessor Definitions." Everything else is working so far.

Here is the code:

#include "sleepy_discord/websocketpp_websocket.h"
#include "config.h"

class myClientClass : public SleepyDiscord::DiscordClient {
public:
    using SleepyDiscord::DiscordClient::DiscordClient;
    void onMessage(SleepyDiscord::Message message) {
        if (message.startsWith(command + "ping")) {
            sendMessage(message.channelID, "Pong!");
        }
    }
};

int main() {
    myClientClass client(token, 2);
    client.run();
}

Here is the exact error list:

`Severity   Code    Description Project File    Line    Suppression State
Warning LNK4098 defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\LINK 1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_init referenced in function _Curl_ldap   Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_unbind_s referenced in function _Curl_ldap   Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_set_option referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_simple_bind_s referenced in function _ldap_win_bind  Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_bind_s referenced in function _ldap_win_bind Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_search_s referenced in function _Curl_ldap   Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_msgfree referenced in function _Curl_ldap    Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_err2string referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_first_entry referenced in function _Curl_ldap    Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_next_entry referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_first_attribute referenced in function _Curl_ldap    Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_next_attribute referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_get_values_len referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_value_free_len referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_get_dn referenced in function _Curl_ldap Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ldap_memfree referenced in function _Curl_ldap    Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__ber_free referenced in function _Curl_ldap    Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(ldap.obj)  1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__IdnToAscii@20 referenced in function _curl_win32_idn_to_ascii Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(idn_win32.obj) 1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__IdnToUnicode@20 referenced in function _curl_win32_ascii_to_idn   Functions   C:\Users\gutkneth\source\repos\YumekoBot\Functions\libcurl_a.lib(idn_win32.obj) 1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK1120 19 unresolved externals Functions   C:\Users\gutkneth\source\repos\YumekoBot\Debug\Functions.exe    1
yourWaifu commented 6 years ago

I'm not sure what went wrong but maybe you need to link some windows libraries like winsock. I think it's Ws2_32.lib for sockets and crypt32.lib for cryptographic stuff.

Tomentos commented 6 years ago

Alright I was able to solve it. I included Ws2_32.lib and crypt32.lib already was included. But those didn't do anything.

I added Wldap32.lib in "Property pages ==> Linker ==> Input ==> Additional Dependencies" which reduced the errors to 3 Errors and 1 Warning.

Then i recompiled curl with the following command: nmake /f Makefile.vc mode=dll VC=17 ENABLE_IDN=no When you do that you need to go to "Property pages ==> Linker ==> Input ==> Additional Dependencies" again and change libcurl_a.lib to libcurl.lib I don't know how others manage their folders but if you include libcurl.lib from the original folder you need to change the name of the included folder too.

Note: I use Visual Studio 2017