I've just installed the VS2012 beta, and upgraded my VS2010 project, it seems to compile as it should, but when linking, I get the following errors:
1>LIBCMTD.lib(excptptr.obj) : error LNK2019: unresolved external
symbol __Atomic_fetch_add_4 referenced in function "unsigned long
__cdecl std::_Inc_atomic_counter_explicit(unsigned long &,enum std::memory_order)"
(?_Inc_atomic_counter_explicit#std##YAKAAKW4memory_order#1##Z)
1>LIBCMTD.lib(excptptr.obj) : error LNK2019: unresolved external
symbol __Atomic_fetch_sub_4 referenced in function "unsigned long
__cdecl std::_Dec_atomic_counter_explicit(unsigned long &,enum std::memory_order)"
(?_Dec_atomic_counter_explicit#std##YAKAAKW4memory_order#1##Z)
Google has no reference to these error messages, which is surprising.
It looks as if __Atomic_fetch_add_4 should be an intrinsic for the fetchadd4 op-code, but it's not (as far as I can tell), the proper intrinsic is _InterlockedIncrement.
I have no idea what could be causing this. Interestingly it comes from excptptr.obj, and I have C++ exceptions disabled in this project. Enabling them made no difference.
Edit:
I notice when googling that this symbol only appears to be referenced by GNU code. Perhaps MS have updated the STL for VS2012 and pulled in some GNU reference code that hasn't been caught yet; needs to be changed to use the MS intrinsic?
I was having a similar problem with a project of mine which was compiled in VS2010 and getting the unresolved external symbol __Atomic_fetch_add_4 error when compiled in VS2012.
I couldn't figure out why it was happening but after a "clean solution" and "rebuild all" the problem went away. I suspect there where old obj files lying around that caused the problem.
Related
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.
This is my first question on this forum, so please forgive me if I do not get it right ;)
I am migrating an old MFC project from VS6 to VS2017, and am having issues linking to the previous HtmlHelp.lib file created via MakeHelp.bat. I assume I need to generate a new one, or replace it with whatever came after, but I am not knowledgeable enough of VS to know what that is. I am also assuming that because I am trying to link a file created with VS6 into a new project compiled in VS2017 that maybe there is some "name mangling" issues due to the difference in compiler versions.
I am getting the following link errors:
error LNK2019: unresolved external symbol "protected: void thiscall XXX::HtmlHelpA(struct HWND *,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT > > const &,int,int)" (?HtmlHelpA#XXX##IAEXPAUHWND__##ABV?$CStringT#DV?$StrTraitMFC_DLL#DV?$ChTraitsCRT#D#ATL#####ATL##HH#Z) referenced in function "protected: void __thiscall XXX::OnHelp(void)" (?OnHelp#XXX##IAEXXZ)
Any help would be greatly appreciated.
I get this error in my program. I don't know what that means. can you help me ?
Error 3 error LNK2019: unresolved external symbol
imp_CrtDbgReportW referenced in function "public: class std::_Vector_const_iterator > > & __thiscall
std::_Vector_const_iterator > >::operator+=(int)"
(??Y?$_Vector_const_iterator#V?$_Vector_val#U?$_Simple_types#PAVCommissionEmployee###std###std###std##QAEAAV01#H#Z) C:\Users\Dell\Documents\Visual
Studio 2012\Projects\Base-Commission Employee\Base-Commission
Employee\main.obj
Take a look here please:
The vector class is going to want to tell you that the at() method
failed in debug mode. Thus the reference to CrtDbgReportW(), the
runtime function that displays diagnostics while debugging. When you
link with /MD, you link with the release version of the run-time
library; the one that doesn't tell you anything and is missing the
CrtDbgReportW() export. Thus the linker error.
You can fix this by removing the _DEBUG define from the preprocessor
definitions. If you don't want to lose that valuable tool, tell us
what goes wrong when you link with /MDd.
If you are building a debug version with a static CRT linking (/MT) then just do this:
#define _ITERATOR_DEBUG_LEVEL 0 before#include<vector> or #include<algorithm> and so on...
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.
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