LNK 2019 - Unresolved External Symbol - c++

I am getting the below link errors.
1>------ Build started: Project: NowHook, Configuration: Debug Win32 ------
1>Compiling...
1>NowHook.CPP
1>Linking...
1>NowHook.obj : error LNK2019: unresolved external symbol __imp__VirtualProtect#16 referenced in function "void __cdecl
1>NowHook.obj : error LNK2019: unresolved external symbol __imp__GetProcAddress#8 referenced in function "void __cdecl
1>NowHook.obj : error LNK2019: unresolved external symbol __imp__LoadLibraryA#4 referenced in function "void __cdecl HookSend(void)" (?HookSend##YAXXZ)
1>C:\Users\JAGAN\Documents\Visual Studio 2008\Projects\HookNow\Debug\NowHook.dll :
fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\JAGAN\Documents\Visual Studio 2008\Projects
I have included
1) Linker/General/AdditionalLibraryDirectories
2) Linker/Input/Additional Dependencies

You are missing kernel32.lib in your Linker/Input/Additional Dependencies
Make sure you are setting the Additional Dependencies for "All Configurations" and "All Platforms".

Related

msvcrtd.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function

I am using gradle to build my c++ library
I added this line to build.gradle file
linkTask.linkerArgs.add("msvcrt${linkTask.name.toLowerCase().contains('debug') ? 'd' : ''}.lib")
Error :
> Task :psfe:linkDebugWindows FAILED
msvcrtd.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
Caching disabled for task ':psfe:linkDebugWindows' because:
D:\a\piv\piv\psfe\build\lib\main\debug\windows\psfe.dll : fatal error LNK1120: 1 unresolved externals
Build cache is disabled
How can I solve this error ?

Visual Studio Community 2017 linker problems - MariaDB

Its my first foray into messing with DB's in programming (specifically MariaDB) in Visual Studio and am not having much luck. It looks like I have configured external linking incorrectly however I am staring at my settings and just not seeing the error. Its probably going to be obvious to more experienced coders out there but I can't see the forest because of the trees.
I have tried compiling in both x86 and 64bit with their respective libraries. I've only included the x86 settings below but they are identical APART from pointing to "program files" instead of "program files x86"
My code is quite simple at the moment:
#include "stdafx.h"
#include <mysql.h>
int main()
{
MYSQL* temp;
temp = mysql_init(NULL);
return 0;
}
but when I try to compile I get the following output.
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>test.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__ntohs#4 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__getservbyname#8 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveExtensionA#4 referenced in function _mysql_optionsv
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathStripPathA#4 referenced in function _mysql_optionsv
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup#8 referenced in function _my_win_init
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup#0 referenced in function _ma_end
1>mariadbclient.lib(ma_pvio.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError#0 referenced in function _ma_pvio_read_async
1>mariadbclient.lib(mariadb_async.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError#0
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError#0
1>mariadbclient.lib(ma_default.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveFileSpecA#4 referenced in function _get_default_configuration_dirs
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__connect#12 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__connect#12
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__getsockopt#20 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__getsockopt#20
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol ___WSAFDIsSet#8 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__bind#12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__closesocket#4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__ioctlsocket#12 referenced in function _pvio_socket_blocking
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__recv#16 referenced in function _pvio_socket_async_read
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__select#20 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__send#16 referenced in function _pvio_socket_async_write
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__setsockopt#20 referenced in function _pvio_socket_fast_send
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__shutdown#8 referenced in function _pvio_socket_close
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__socket#12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__WSASetLastError#4 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__getaddrinfo#16 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__freeaddrinfo#4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA#20 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext#8 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptDestroyKey#4 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptImportKey#24 referenced in function _ma_schannel_load_private_key
1>d:\nikuya\documents\visual studio 2017\Projects\test\Debug\test.exe : fatal error LNK1120: 27 unresolved externals
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My settings are below -
VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql\include
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
Linker -> Additional Dependancies -> mariadbclient.lib
Linker -> Additional Dependancies -> libmariadb.lib
Any help would be appreciated and please ask if any further info is needed.
note: I also tried including windows.h out of desperation but no dice.
The key line here is:
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
You are attempting to use a library which is incompatible with libcmt which is the multithreaded c run time library.
It is likely that you are compiling with a different switch (often /MD or /MT) somewhere to what was used to build the mariadb libs.
See here for more info:
https://msdn.microsoft.com/en-us/library/aa267384(v=vs.60).aspx

Visual studio 2015 c++ and assembly not building

I recently wanted to start learning assembly, but I have been having some problem setting up my project to build.
What I want to have is a C++ and assembly project, but it is currently not working. My assembly code shown below builds just fine:
ExitProcess PROTO
.data
.code
main proc
mov rax, 8
mov rcx, 0
call ExitProcess
main endp
end
but the moment I add a cpp file to my project I get a load of linker errors:
void ToDo()
{
int i = 0;
}
Errors:
1>------ Build started: Project: AssemblyTest, Configuration: Debug x64 ------
1> test.cpp
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function _CRT_RTC_INITW
1>MSVCRTD.lib(_error_.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l
1>MSVCRTD.lib(_error_.obj) : error LNK2001: unresolved external symbol __C_specific_handler
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath##YAHPEB_WPEA_W_K#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath##YAHPEB_WPEA_W_K#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath##YAHPEB_WPEA_W_K#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPEAUHINSTANCE__##XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPEAUHINSTANCE__##XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPEAUHINSTANCE__##XZ)
1>C:\Users\***\Desktop\AssemblyTest\x64\Debug\AssemblyTest.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Does anybody know what is wrong with my setup and how to fix it?
You're linking your project with only part of the C runtime (CRT) libary, msvcrtd.lib. You also need to link with the libraries vcruntimed.lib and ucrtd.lib. The former is part of Visual Studio 2015 itself while the later is part of the Windows 10 SDK that was installed along Visual Studio. Normally C++ projects automatically link with these libraries, but apparently your project is setup not to.
You may be following instructions meant for an older version of Visual Studio which only required linking with one CRT library file. This changed due to a refactoring of the CRT with Visual Studio 2015.

VC++ Library Miss while compiling application? unzip.obj : error LNK2019

I try to compile VC++ application and get the error message as below. Is there anyone who know what the library I may be missing? Any advice & suggestion are appreciated.
My Environment:
VC++ 2010
zlib-1.2.8
boost_1_57_0
icu
1>------ Build started: Project: paloserver, Configuration: Debug Win32 ------
1> Creating library C:/Users/a992788/Virtual Machines/Documents/Application/Palo/Palo 3.x Source Code/palo-code-546/molap/server/5.1/SourceCode/Debug/paloserver.lib and object C:/Users/a992788/Virtual Machines/Documents/Application/Palo/Palo 3.x Source Code/palo-code-546/molap/server/5.1/SourceCode/Debug/paloserver.exp
1>unzip.obj : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function _unzOpenCurrentFile3
1>unzip.obj : error LNK2019: unresolved external symbol _inflate referenced in function _unzReadCurrentFile
1>unzip.obj : error LNK2019: unresolved external symbol _crc32 referenced in function _unzReadCurrentFile
1>zip.obj : error LNK2001: unresolved external symbol _crc32
1>unzip.obj : error LNK2019: unresolved external symbol _inflateEnd referenced in function _unzCloseCurrentFile
1>zip.obj : error LNK2019: unresolved external symbol _get_crc_table referenced in function _zipOpenNewFileInZip4_64
1>zip.obj : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function _zipOpenNewFileInZip4_64
1>zip.obj : error LNK2019: unresolved external symbol _deflate referenced in function _zipWriteInFileInZip
1>zip.obj : error LNK2019: unresolved external symbol _deflateEnd referenced in function _zipCloseFileInZipRaw64
1>C:\Users\a992788\Virtual Machines\Documents\Application\Palo\Palo 3.x Source Code\palo-code-546\molap\server\5.1\SourceCode\Debug\paloserver.dll : fatal error LNK1120: 8 unresolved externals
Add reference to the zdll.lib in your source.
#pragma comment (lib, "zdll.lib")

unresolved external symbol in eclipse cdt

I try to build cpp file using eclipse cdt. Linker throws "unresolved external symbol", however path to lib file that contains implementation for function is listed in LIB environment variable on Project properties->C/C++ Build->Environment
What am I doing wrong?
UPD I try to build file. There is lib RpcRT4.Lib on the path C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
And linker fails:
**** Build of configuration Debug for project test cpp ****
**** Internal Builder is used for build ****
link /debug /nologo /OUT:test cpp.exe main.obj
main.obj : error LNK2019: unresolved external symbol __imp__RpcStringFreeA#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)"(?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterClassA#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidToStringA#8 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidCreate#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA#16 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc##YGJPAUHWND__##IIJ#Z)
main.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage#4 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc##YGJPAUHWND__##IIJ#Z)
main.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA#8 referenced in function "void __cdecl DeInitialize_DestroyWindowClass(void)" (?DeInitialize_DestroyWindowClass##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA#48 referenced in function "bool __cdecl Initialize_CreateMainWindow(void)" (?Initialize_CreateMainWindow##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow#4 referenced in function "void __cdecl DeInitialize_DestroyMainWindow(void)" (?DeInitialize_DestroyMainWindow##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA#4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage#4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__GetMessageA#16 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__PostMessageA#16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread##YAXPAX#Z)
main.obj : error LNK2019: unresolved external symbol __imp__SendMessageA#16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread##YAXPAX#Z)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterWindowMessageA#4 referenced in function _main
test cpp.exe : fatal error LNK1120: 15 unresolved externals
Build error occurred, build is stopped
Time consumed: 2438 ms.
And environment settings for project
I'm not entirely clear on whether you've already done this based on the question, but just adding the directory to your linker's search path isn't enough for any compiler/linker I've ever used. There could be hundreds of different libraries in there, even different versions of the same library, and the linker has no idea which ones you do and don't want. You need to tell it, explicitly, to link against the library using the appropriate parameter.
It looks like you're using the Microsoft linker, which I've never used, so I can't help you with the specific flag but it should be easy enough to find what it is in the documentation if that's the issue. I presume Eclipse has a method of specifying this in the GUI as well which should be generic across the various compilers it supports.