2
votes

I've got an project that started as a client program. Later on I decided to implement some client to server communication to make kind of a login system. I developed it in plain HTTP post requests and it worked.

Recently I've updated my server to HTTPS and now the plain HTTP post request doesn't work any more, and since I'm going to transfer sensitive data over the web I decided to implement SSL also on my client. The alternatives I've seen includes Libcurl with OpenSSL/WolfSSL or Boost with OpenSSL. I decided to go on the Libcurl way.

So now, I've tried downloading some precompiled libcurl builds and such and with no success on linking to it, giving me some kind of this error:

1>Attacker.obj : error LNK2001: unresolved external symbol __imp__PostMessageW@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__EnableWindow@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextLengthA@4
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetOpenFileNameA@4
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetClientRect@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SendMessageA@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SetWindowTextA@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextA@12
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__RedrawWindow@16
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__SetWindowPos@28
1>GEFunc.obj : error LNK2001: unresolved external symbol __imp__DestroyWindow@4
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreateSolidBrush@4
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreatePen@12
1>FormVarClass.obj : error LNK2001: unresolved external symbol __imp__CreateFontW@56
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__SetParent@8
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__MoveWindow@24
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__AttachThreadInput@12
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__GetWindowLongA@8
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__SetWindowLongA@12
1>GameClient.obj : error LNK2001: unresolved external symbol __imp__GetWindowRect@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__EndPaint@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__BeginPaint@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__LoadIconW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
1>GUI.obj : error LNK2001: unresolved external symbol __imp__IsDialogMessageW@8
1>GUI.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageW@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExW@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__CloseWindow@4
1>GUI.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcW@16
1>GUI.obj : error LNK2001: unresolved external symbol __imp__GetMessageW@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__SHGetFolderPathA@20
1>Mem.obj : error LNK2001: unresolved external symbol __imp__EnumWindows@8
1>Mem.obj : error LNK2001: unresolved external symbol __imp__IsWindowVisible@4
1>Mem.obj : error LNK2001: unresolved external symbol __imp__GetWindow@8
1>Mem.obj : error LNK2001: unresolved external symbol __imp__GetWindowThreadProcessId@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__InvalidateRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__ExtTextOutW@32
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__FillRgn@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__RoundRect@28
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CombineRgn@16
1>Overrides.obj : error LNK2001: unresolved external symbol enter code here__imp__ScrollWindow@20
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetScrollPos@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__DeleteObject@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetBkColor@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__EnableScrollBar@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetCursor@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetBkMode@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetTextColor@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__GetSysColor@4
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CreateRectRgn@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__CreateRoundRectRgn@24
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__DrawTextA@20
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SendMessageW@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__UnionRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__FillRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__InflateRect@12
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SelectObject@8
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__SetScrollInfo@16
1>Overrides.obj : error LNK2001: unresolved external symbol __imp__GetWindowTextLengthW@4
1>Window.obj : error LNK2001: unresolved external symbol __imp__TrackMouseEvent@4
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strerror
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurl.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp____sys_nerr
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurl.lib(netrc.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp__fputs
1>libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(parsedate.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(imap.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(http.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(digest.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(ftplistparser.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(http.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurl.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(url.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurl.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp__read
1>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
1>libcurl.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp__write
1>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
1>libcurl.lib(curl_threads.obj) : error LNK2001: unresolved external symbol __imp___beginthreadex
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp__close
1>OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp__open
1>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
1>libcurl.lib(file.obj) : error LNK2001: unresolved external symbol __imp___fstat64
1>libcurl.lib(smb.obj) : error LNK2001: unresolved external symbol __imp___getpid
1>libcurl.lib(system_win32.obj) : error LNK2001: unresolved external symbol __imp___mbspbrk
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__feof
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__ferror
1>libcurl.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp___stat64

Then I tried building the Libcurl from myself and downloaded the latest version from their site and built it from scratch, using the "LIB Debug - LIB OpenSSL" build option. Linked to OpenSSL libs and pointed to their include directories, it compiled and built me the libcurl.lib file.

So, in my main project, now I included both the libcurl include dir and the openssl include dir, then I linked both of these corresponding Lib folder so it should be alright.

http://prntscr.com/eg389b.

Then in the linker additional dependencies I've set to "crypt32.lib;ws2_32.lib;wldap32.lib;libeay32.lib;ssleay32.lib;libcurld.lib". This is all the steps I've found that should be done to work, but even then I've been getting the exactly same unresolved external symbol error.

PS: Starting from scratch wouldn't be an option.

PS2: For the sake of portability, I would prefer building my program as himself without the need of external DLLs other than the VC++ redist.

EDIT 1

By now, using the method described here LibCurl - Release Static Lib linking problems I've reduced the number of unresolved external symbols drastically and traced them back to the libcurld.lib, OLDNAMES.lib and MSVCRTD.lib. So only the three of those are appearing and bugging me out.

1>libcurld.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp__strerror referenced in function _Curl_strerror
1>libcurld.lib(curl_gethostname.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>libcurld.lib(rand.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http_ntlm.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(ntlm.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(pingpong.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(openssl.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(imap.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(conncache.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(warnless.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(inet_ntop.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(connect.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(wildcard.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(sendf.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(slist.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(multi.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(asyn-thread.obj) : error LNK2001: unresolved external symbol __imp___wassert
1>libcurld.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp____sys_nerr referenced in function _Curl_strerror
1>libcurld.lib(cookie.obj) : error LNK2019: unresolved external symbol __imp__fgets referenced in function _get_line
1>libcurld.lib(netrc.obj) : error LNK2001: unresolved external symbol __imp__fgets
1>libcurld.lib(cookie.obj) : error LNK2019: unresolved external symbol __imp__fputs referenced in function _cookie_output
1>libcurld.lib(telnet.obj) : error LNK2019: unresolved external symbol __imp____stdio_common_vsscanf referenced in function _sendsuboption
1>libcurld.lib(rtsp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(http_proxy.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(parsedate.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(imap.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp____stdio_common_vsscanf
1>libcurld.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__strstr referenced in function _ftp_statemach_act
1>libcurld.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(digest.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(ftplistparser.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(vtls.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp__strstr
1>libcurld.lib(vtls.obj) : error LNK2019: unresolved external symbol __imp__fread referenced in function _Curl_pin_peer_pubkey
1>libcurld.lib(url.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(formdata.obj) : error LNK2001: unresolved external symbol __imp__fread
1>libcurld.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function _curlx_read
1>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
1>libcurld.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__write referenced in function _curlx_write
1>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
1>libcurld.lib(curl_threads.obj) : error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function _Curl_thread_create
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp__close referenced in function _file_done
1>OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp__open referenced in function _file_connect
1>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
1>libcurld.lib(file.obj) : error LNK2019: unresolved external symbol __imp___fstat64 referenced in function _file_do
1>libcurld.lib(smb.obj) : error LNK2019: unresolved external symbol __imp___getpid referenced in function _smb_format_message
1>libcurld.lib(system_win32.obj) : error LNK2019: unresolved external symbol __imp___mbspbrk referenced in function __tcspbrk
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp__feof referenced in function _Curl_getformdata
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp__ferror referenced in function _Curl_getformdata
1>libcurld.lib(formdata.obj) : error LNK2019: unresolved external symbol __imp___stat64 referenced in function _AddFormData
1>MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
2
In visual studio you need both .lib and .dll files. Using .lib files you link your program in compile time and using .dll file you link in runtimemadz
Well, I tought that the difference between the lib and DLL would be that lib is static(built in your program) and the DLL would be dynamic(you need it externally so my program acess the exported functions). But still, could anyone confirm this?Eduardo Roeder
For .DLL files you have two options: 1) You can load the .dll dynamically with LoadLibrary() and import the needed functions by your own, or 2) you can link to the 'import library' (also having the extension .lib) that belongs to the .dll. However the first error line Attacker.obj : error LNK2001: unresolved external symbol __imp__PostMessageW@16 tells, that your problem is unrelated to libcurl. You also need to link to the windows runtime. Try link to these libraries too: kernel32.lib;user32.lib;gdi32.libLaszlo
@Laszlo thanks! I was doing this exactly now reading stackoverflow.com/questions/7369663/… by now i've reduced the number of erros and traced almost all of them to libcurld.libEduardo Roeder

2 Answers

0
votes

Can you describe how you built libcurl?

It looks like you are not using the same version of the c library in your project and in libcurl. Are you using the same compiler? Visual Studio calls this the "Platform Toolset". I remember compiling libcurl in the past, but I didn't go the static lib route. It seems to be a problem with a mismatch of the C library. When you try to link this library to another program with a different version of the C library, it becomes ambiguous which functions you are referring to.

I just checked the libcurl bundle from their website. There is a sln project curl-7.53.1\projects\Windows\VC14 that you should open. From there, make sure that you select "LIB Debug - [ssl library choice]" and that you're using the same arch, like 32 bits or 64 bits, in both projects.

I don't think that simply adding a single switch to the compiler is enough.

Something I've just seen on curl website :

As a general rule, building a DLL with static CRT linkage is highly discouraged, and intermixing CRTs in the same app is something to avoid at any cost.

1
votes

You must change the libcurl compile option to Mtd/Mt.