Understanding VSC++ linker errors - c

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

Related

Linker error while building libevent project

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.

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".

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.

C linker behaves strange gives unresolved externals where it shouldn't

I have a problem with linking a program, the strange thing about that is that functions that linker can't resolve, sit in the same file near the functions that are resolved without a problem.
I can't post files themselves in the message as they are pretty large, though ===> here <=== is the project ready to be built.
Here are build errors:
error LNK2019: unresolved external symbol _leveldb_filterpolicy_destroy referenced in function _main
error LNK2019: unresolved external symbol _leveldb_options_set_filter_policy referenced in function _main
error LNK2019: unresolved external symbol _leveldb_filterpolicy_create_bloom referenced in function _main
error LNK2019: unresolved external symbol _leveldb_filterpolicy_create referenced in function _main
error LNK2019: unresolved external symbol _leveldb_filterpolicy_create referenced in function _main
Here is the full-size screenshot showing error messages
Here is the implementation of the function that cant be found:
Here is the implementation of the function that sits in the same file and is easily found by the linker:
I've found-out what was causing the problem, I've updated the version of leveldb to a newer one. The newer version introduced several new functions (the ones that are being unresolved). But I haven't updated the .def file which contains all exports, and functions weren't exported as a result...

Resources