Linker error while building libevent project - c

I have one project which uses libevent libraries and i am compiling it VS2017. It runs in linux perfectly. I am getting errors like below:
1>ftpcmd.obj : error LNK2019: unresolved external symbol evutil_snprintf referenced in function do_client_read
1>ftpcmd.obj : error LNK2019: unresolved external symbol evutil_inet_pton referenced in function handle_pasv
1>ftpdata.obj : error LNK2001: unresolved external symbol evutil_inet_pton
1>ftpcmd.obj : error LNK2019: unresolved external symbol bufferevent_free referenced in function fs_client_free
1>ftpdata.obj : error LNK2001: unresolved external symbol bufferevent_free
Does anyone know how to link libevent with project? I read some question related to that and they say i need to compile libevent using VS commad prompt. I tried that with nmake -f Makefile.nmake libevent-2.1.8-stable but it failed.
Thanks in advance.

Related

IPP patched ZLIB missing symbols

I patched ZLIB 1.2.11 using IPP 2016 (and 2019), all went fine, all compiled fine (using MSVC). But linker comes with following missing symbols (I added all necessary libs, and I actually tried adding all libs from IPP at all)
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77FastestGetStat_8u referenced in function _custDeflateUpdateTable
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77Fastest_8u referenced in function _lz77_encode_call
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77FastestPrecompHeader_8u referenced in function _lz77_encode_call
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77Fast_8u referenced in function _lz77_encode_call
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77Slow_8u referenced in function _lz77_encode_call
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77FastestGenHuffTable_8u referenced in function _zzdeflateGetTabLen
1>zlib_x32_debug.lib(deflate.obj) : error LNK2019: unresolved external symbol _ippsDeflateLZ77FastestGenHeader_8u referenced in function _zzdeflateGetTabLen
Then I even tried to search the libs for these symbols and they are nowhere to be found... Any ideas?
Please, check that you link proper IPP library bit version to your object files. I mean, 32-bit libraries should be linked to 32-bit object files. Looks, like "zlib_x32_debug.lib" is a 64-bit static lib (and linker looks for 64-bit variant of functions). As far as I remember, 32-bit functions have object files names like "blabla#number" and 64-bit functions are named as "_blabla".

Windows linking to libcurl_a.lib

I built libcurl following the instructions for building libcurl as a static library in the curl/winbuild directory to the letter. It spat out a libcurl_a.lib, a collection of .h files, which I moved into folders that I promptly added to the PATH. I then attempt to build my program with the command
cl (*my source files*) /IC:/PATH_addon/include libcurl_a.lib Ws2_32.lib Wldap32.lib /DCURL_STATICLIB /link /LIBPATH:C:/PATH_addon/lib
Note:
I am building from the command line as the code was not written in an IDE, or on this machine
C:/PATH_addon/ is a folder where I dump all the things that need to be linked into path (it is linked to my path) so that I don't pollute the default path, or my system32 folder
However when I run the command, it tells me that there are 12 unresolved symbols:
libcurl_a.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(cookie.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(hostip.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(http.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp___time64
libcurl_a.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(curl_sspi.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(url.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(strerror.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__strncpy
libcurl_a.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function _curlx_read
OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp__read
libcurl_a.lib(warnless.obj) : error LNK2019: unresolved external symbol __imp__write referenced in function _curlx_write
OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp__write
libcurl_a.lib(parsedate.obj) : error LNK2019: unresolved external symbol __imp___gmtime64 referenced in function _Curl_gmtime
libcurl_a.lib(strerror.obj) : error LNK2019: unresolved external symbol __imp__strerror referenced in function _Curl_strerror
libcurl_a.lib(curl_threads.obj) : error LNK2019: unresolved external symbol __imp___beginthreadex referenced in function _Curl_thread_create
libcurl_a.lib(smb.obj) : error LNK2019: unresolved external symbol __imp___getpid referenced in function _smb_format_message
libcurl_a.lib(file.obj) : error LNK2019: unresolved external symbol __imp__close referenced in function _file_done
OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp__close
libcurl_a.lib(file.obj) : error LNK2019: unresolved external symbol __imp__open referenced in function _file_connect
OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp__open
libcurl_a.lib(mime.obj) : error LNK2019: unresolved external symbol __imp__access referenced in function _curl_mime_filedata
OLDNAMES.lib(access.obi) : error LNK2001: unresolved external symbol __imp__access
MSVCRT.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
Why can't these symbols be resolved, and is there a way to fix this?
Solution (thanks in part to the incredible #Hans Passant):
Adding the /NODEFAULTLIB:LIBCMT flag fixed the issue and allowed for a successful compile and execution.

Understanding VSC++ linker errors

I'm trying to build a simple command line application which uses WinUSB in Visual Studio 2013. I'm getting no compile errors, but lots of linker errors. The following are some of them:
winusblnk.obj : error LNK2019: unresolved external symbol imp__Sleep#4 referenced in function _msDelay
winusbnet.obj : error LNK2001: unresolved external symbol __imp__Sleep#4
What do the references to obj files mean? How do I see these OBJ files? How can I inspect them and see what functions they have inside them?
What does __imp__Sleep#4 mean? What do all the underscores mean? What does the #4 mean? How do I find the reference to this symbol?
What is the difference between error LNK2019 and error LINK2001?
There are lots more similar errors in winusbxxx.obj files.
errhnd.obj : error LNK2019: unresolved external symbol __imp__GetLocalTime#4 referenced in function _logerr
readtemp.obj : error LNK2019: unresolved external symbol _ReadTemperature referenced in function _main
Same questions.
MSVCRTD.lib(gs_report.obj) : error LNK2019: unresolved external symbol __imp__IsDebuggerPresent#0 referenced in function ___raise_securityfailure
MSVCRTD.lib(error.obj) : error LNK2001: unresolved external symbol __imp__IsDebuggerPresent#0
How do I look at the contents of these lib files, and see which obj files they contain, and which functions each of those contain?
There are lots more errors in MSVCRTD.lib
I hope someone can give me some guidance on finding the cause of all these errors.
Thanks - Rowan

Fatal error LNK1120 when compiling c project

I tried to compile main.c from this project Emacs-FullScreen-Win32 by using visual studio developer command prompt but I get the following error:
main.c
Microsoft (R) Incremental Linker Version 11.00.60610.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
main.obj : error LNK2019: unresolved external symbol __imp__ShowWindowAsync#8 re
ferenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__SetWindowPos#28 refe
renced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__MessageBoxW#16 refer
enced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__GetWindowLongW#8 ref
erenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__SetWindowLongW#12 re
ferenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__FindWindowW#8 refere
nced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__CommandLineToArgvW#8
referenced in function _is_topmost_requested
main.exe : fatal error LNK1120: 7 unresolved externals
Those unresolved external problems are likely due to you not properly linking the libraries that those functions are from. In your project settings, go to project properties. Expand configuration properties, then expand linker. In the linker's input settings, you can specify libraries that the program requires in the "additional dependencies" option.

Visual Studio 2013 and libpng [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 8 years ago.
I'm trying to write a simple PNG file using libpng in C using VS2013. I installed libpng from Nuget and included png.h, but I can't compile. I get this as my output:
1>main.obj : error LNK2019: unresolved external symbol png_create_write_struct referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_set_longjmp_fn referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_create_info_struct referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_write_info referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_destroy_write_struct referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_init_io referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_free_data referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_set_IHDR referenced in function writeImage
1>main.obj : error LNK2019: unresolved external symbol png_set_text referenced in function writeImage
I've tried playing with the compilation settings, but nothing seems to make it work. I don't get any red lines under any of those declarations when I write the code, so VS must be seeing some of the code.
Besides including png.h you must also link with the appropriate import library (probably called libpng.lib or something similar). In Visual Studio, you would add this to Project Settings → Linker → Input → Additional Dependencies.

Resources