LINK ERROR in VC++ - visual-c++

I needed help making sense out of the following LNK error which i am getting.
SwitchFunctions error LNK2019: unresolved external symbol "__declspec(dllimport) ??$?8DU?$char_traits#D#std##V?$allocator#D#1##std##YA_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##0#PBD#Z" (__imp_??$?8DU?$char_traits#D#std##V?$allocator#D#1##std##YA_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##0#PBD#Z) referenced in function "??$find#Viterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##std##PBD#std##YA?AViterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##0#V120#0ABQBD#Z" (??$find#Viterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##std##PBD#std##YA?AViterator#?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##0#V120#0ABQBD#Z)

Have you checked whether you have included all necessary dlls or lib files in your project settings?
Such an error usually indicate that you have used a function which definition is found, but implementation is not. Usually in the case of external libraries, the implementation is inside a dll or a static lib. Failure to provide the dll or the static lib will cause the linking to fail.

Which version of Visual Studio are you using? This might be relevant for VS2005:
Link error using a CString derived class from a DLL

Related

Linker error lnk2001 even though the unresolved symbol is defined

I have researched more into the problem and posted a more detailed question with my findings here: Rust, how to use global variable from DLL? C++ equivalent requires __declspec(dllimport)
Original question:
Summary:
When linking my project with MSVC 2019's link.exe, I am getting errors such as unresolved external symbol jl_module_type. These symbols are defined in a file julia.lib, which I have verified using dumpbin /exports julia.lib. This file is passed as an argument to link.exe, and yet, it still complains about unresolved symbols. It looks like all the symbols that failed to be linked are variables rather than functions.
More information:
julia.lib has been renamed from libjulia.dll.a, and it corresponds to another file libjulia.dll. They were built with Cygwin/MinGW, but AFAIK this should not affect things. The actual project this is being used in is written in Rust, so link.exe is being invoked automatically by Rust's cargo tool. It is configured to build my project as a DLL.

Unable to add a NIDAQ dll reference to Visual Studio 2012

I have a project which is simulating a graphical environment. What I need in this program is to integrate it with NIDAQ library. Currently I am getting LNK2019 of unresolved external symbol.
LNK2019: unresolved external symbol DAQmxCreateTask referenced in function "public: virtual void __cdecl sofa::component::behaviormodel::MyBehaviorModel::updatePosition(double)" (?updatePosition#MyBehaviorModel#behaviormodel#component#sofa##UEAAXN#Z) C:\Sofa\applications\plugins\NIPlugin\MyBehaviorModel.obj NIPlugin
I have included header file and lib file into my project but as my project is very big and includes lots of library and sub projects it seems that I have to add dynamic library of national instrument to the project as well. However I can not add any new reference to my new code in reference option of my project (there is no browse option abailable). I have also tried adding the path of the .dll file to the additional directory of the project and it doesn't seem to work. but when I add my .dll to additional dependency in Input-->Linker section of the project I get LNK1107 error.
LNK1107: invalid or corrupt file: cannot read at 0x2D0 C:\git\sofa\v15.12\src\lib\win64\nicaiu.dll 1 NIPlugin 1
Do you have any idea how I can make VS read my .dll file?

error LNK2019: unresolved external symbol referenced in function main

I'm using a library to generate multimodal optimization functions using VS2010. I include the header file of the library and tell VS where the library directory is; however, there is no *.lib file that comes with it, just source files and header files, so I can't point VS to "Additional Library Directories".
If I just include the header file and run my code it works fine. If I call any method from that library I get the LNK2019 error:
error LNK2019: unresolved external symbol "void __cdecl g_initialize(char *)" (?g_initialize##YAXPEAD#Z) referenced in function main".
I looked around and everyone is saying I should link the library, but I don't have a library file to begin with. What should I do??
Regards,
There're 2 ways if you have implementation of those header files.
1) You can add it to you project.
2) To compile library yourself, and you will get *.lib files. After this add it to you project.
Read documentation of this library how to use it.
Also you can check if there's implementation methods/functions which declared in header files.

Compile Win32 application without particular dependencies or size bloat

I am trying to build a small Win32 application using Visual C++ 2008, but I want it to run on any modern Windows machine without having to ship additional libraries and without having to bloat its size linking them statically.
I have read many articles around the internet about this topic, like this one.
I understood that a good idea would be to dynamically link my project to msvcrt.dll which can be found in any modern Windows being a system dll, on the contrary of newer runtimes like msvcr90 which change with each new Visual Studio version.
So in the linker options,
I ignored all default libraries (/NODEFAULTLIB)
I added msvcrt.lib to the additional dependencies
But I get a bunch of "unresolved external symbol" errors when compiling, like these ones:
1>StubLib.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall std::bad_cast::~bad_cast(void)" (??1bad_cast#std##UAE#XZ)
1>StubLib.obj : error LNK2001: unresolved external symbol "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast#std##QAE#PBD#Z)
1>StubLib.obj : error LNK2001: unresolved external symbol "public: __thiscall std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast#std##QAE#ABV01##Z)
1>StubLib.obj : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF#std##3JB)
I also tried to use some alternative C++ runtime libraries designed to reduce size bloat like Minicrt, WCRT etc. but in any case I get "unresolved external symbol" errors.
Any help is greatly appreciated.
The "bloat" in this case comes from the use of the STL. So unless you want to refactor your code to get rid of the STL references, you may simply be out of luck.
However, I can suggest using the WDK to build the application. With Windows XP the msvcrt.dll was "knighted" to a system DLL (i.e. always on board, no need for redistributables) and to my knowledge it was also included in Windows 2000 SP4+SRP. So if these minimum requirements are okay for you, use the WDK to build your application and all the "bloat" will be in DLLs that should be on any supported system already.

Link Error while compiling vc++ project

I am getting the following error.
error LNK2001: unresolved external symbol __localtime64_s
On searching on the internet i found that there is a library WINMM.LIB which is needed to be included. So i added this library in the project options.
But,it still does not help.
Can somebody help in this?
The _s suffix indicates that its actually probably one of the "safe" apis added to Visual Studio 2005 or 2008. There are two leading _'s - the first indicates the function decoration - an extern "C" function using the __cdecl calling convention. The next '_' inidcates that the functions is an OEM (Microsoft in this case) extension to the c-runtime library.
Specifically it seems to be a worker function invoked from 'Program Files\Visual Studio\VS\include\time.inl' when the safe 'localtime' function is called.
So, at a guess I would say that you are not linking in the c-runtime libraries correctly into your application. Are you using any options like "exclude default libraries" or are excluding any specific libraries in your projects settings?

Resources