Visual Studio doesn't compile, ATL error - c++

I have uninstalled and reinstalled visual studio 2013 and always the same error on compiling:
Error 1837 error LNK2019: unresolved external symbol "int __cdecl ATL::_AtlInitializeCriticalSectionEx(struct _RTL_CRITICAL_SECTION *,unsigned long,unsigned long)" (?_AtlInitializeCriticalSectionEx#ATL##YAHPAU_RTL_CRITICAL_SECTION##KK#Z) referenced in function "public: long __thiscall ATL::CComCriticalSection::Init(void)" (?Init#CComCriticalSection#ATL##QAEJXZ)

AFAIK this function is membe of the atls.lib, Check your /verbose inker output if this library is included.
The command link /dump /symbols atls.lib Shows me that this Symbol is defined in that file and is included in my ATL projects.

it is very probably, that you are trying to compile sources that have included
their own atl header file implementation, just for compatibility satisfaction. In that case there in header files must be some pre-processor definition e.g. VBOX_COM_NO_ATL, which will tell not to use ATL at all.
to find the conflict - include atlcore.h in your source and see if it conflicts with some another atl header in your library/source code.

Related

Link errors with GraphicsMagick

I downloaded and compiled GraphicsMagick, 1.3.23, Q16, x64, StaticMT version. I had to convert the Visual Studio 7 solution generated by GraphicsMagick's build utility to Visual Studio 2015 format. I linked my project to CORE_DB_magick_.lib and CORE_DB_Magick++_.lib.
When the linker ran, it produced unresolved external symbols when linking InitializeMagick() and DestroyMagick()
1>wtd.lib(WebController.obj) : error LNK2019: unresolved external symbol __imp_DestroyMagick referenced in function "public: __cdecl Wt::WebController::~WebController(void)" (??1WebController#Wt##QEAA#XZ)
1>wtd.lib(WebController.obj) : error LNK2019: unresolved external symbol __imp_InitializeMagick referenced in function "public: __cdecl Wt::WebController::WebController(class Wt::WServer &,class std::basic_string,class std::allocator > const &,bool)" (??0WebController#Wt##QEAA#AEAVWServer#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##_N#Z)
I can't understand why the symbols are not being linked. Any ideas?
Apparently, GraphicsMagick Static versions do not link properly.
What is your project type? I had a similar problem when trying to link the GraphicsMagick libraries to a DLL.
The clue here is that __imp is the function decoration for DLL imports, so you're trying to link with DLL functions.
The problem is that the header magick/common.h, when linked to a DLL project, reads the current configuration of the Visual Studio pre-processor environment to determine which mode the library is in, which is obviously wrong if you're trying to link static libraries into your DLL, for example. In this case, it defines MagickExport to __declspec(dllimport).
AFAIK this is a bug in the library. For proper static build support, magick/common.h needs to do something like read information from the magick/magick_config.h to determine what mode the library was actually built in and define MagickExport appropriately.
Since your library is statically linked, you can fix this by commenting out everything in the define:
#if defined(MSWINDOWS) && !defined(__CYGWIN__)
and replacing it with:
#define MagickExport
#define ModuleExport
#define MagickGlobal

LNK2019 Error Header is included but not linked?

I have some classes and headers that are external to my program that i wish to use. I am using MSVC2013 and have specified the location of these files in the "Additional include directories" entry in the project settings window. Intellisense recognises the paths and provides the appropriate syntax highlight and my program compiles fine except at the end it throws LNK2019 errors for any usage of these classes. Is there another place in linker settings I need to specify to link external files or am i missing something obvious here.
Error messages:
MainWindow.obj : error LNK2019: unresolved external symbol "public: __cdecl QPropertyEditorWidget::QPropertyEditorWidget(class QWidget *)" (??0QPropertyEditorWidget##QEAA#PEAVQWidget###Z) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow##QEAA#PEAVQWidget###Z)
Header files typically provide the API and/or data structures for some other code (most likely a library). With the headers you know about the "other" code, but you don't actually "have it" in your program.
Specifying where to find the headers is only half of the problem. You also need to specify where to find the object files (or libraries), and which objects or libraries to link against.

Why is visual studio 2010 looking for __thiscall rather than __cdecl calling conventions?

Overall I am trying to link an opencv test program with the opencv libraries I compiled using 64-bit visual studio 2010 professional. An example error is:
1>webcamtest.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::VideoCapture::isOpened(void)const " (?isOpened#VideoCapture#cv##UBE_NXZ)
The question is why __thiscall, when opencv_highui249.dll which it is linked with contains
Symbol name : ?isOpened#VideoWriter#cv##UEBA_NXZ (public: virtual bool __cdecl cv::VideoWriter::isOpened(void)const )
__cdecl makes sense, which suggests that the library is built correctly.
When linking the test program, opencv_highui249.dll is being searched, so the build flags appear to be correct, but apparently I am missing something?
Are you sure you used x64 libraries?
Microsoft reduced the calling conventions in x64. See here. Basically everything is now __fastcall.
The compiler can still use __thiscall but it is ignored(MSDN link). So your test program is fine but your library looks wrong.
__thiscall is the default calling convention in VS for member functions of classes. Perhaps the header files are missing the __cdecl specifier, or the compile flags are incorrectly set so a relevant #define for it isn't being set.
__thiscall is the default for class member functions in MSVC, you either need to compile OpenCV with the same settings, or explicitly use __cdecl in the header definitions.

Which library I need to add? : error LNK2019

Error 20 error LNK2019: unresolved
external symbol "public: __thiscall
CAnyseeUSBTVControllerDlg::CAnyseeUSBTVControllerDlg(class
CWnd *)"
(??0CAnyseeUSBTVControllerDlg##QAE#PAVCWnd###Z)
referenced in function "int __cdecl
Init(void)"
(?Init##YAHXZ) anyseeUSBTVControllerDlg.obj anyseee30
I have this error when I want compile my win32 dll project in visual studio 2008.
Also second error (propably linked with first):
Error 21 fatal error LNK1120: 1
unresolved
externals .\Debug/anyseeUSBTVController.exe anyseee30
Which library I need to add to linker? I've read that it is the problem.
You need to add the library that contains the CAnyseeUSBTVControllerDlg class. Since a web search for CAnyseeUSBTVControllerDlg returns nothing, the library seems to be a private library without public documentation.
If you only have class declaration and do not have class implementation, then you need to check with whoever gave you that header file. Ask them for the library.
Generally, Libraries come with header files. Implementation will be inside the library.
By including those header files, we can use library classes/functions.
If header file is written by you, then you need to implement the class in a c++ file.

fftw in Visual Studio?

I'm trying to link my project with fftw and so far, I've gotten it to compile, but not link. As the site said, I generated all the .lib files (even though I'm only using double precision), and copied them to C:\Program Files\Microsoft Visual Studio 9.0\VC\lib, the .h file to C:\Program Files\Microsoft Visual Studio 9.0\VC\include and the .dll to C:\windows\system32.
I've copied the tutorial program, and the exact error I am getting is:
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_free referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_destroy_plan referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_execute referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_plan_dft_1d referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
1>hw10.obj : error LNK2019: unresolved external symbol __imp__fftw_malloc referenced in function "bool __cdecl test(void)" (?test##YA_NXZ)
So, what could be wrong with my project setup? Thanks!
My case
Using FFTW in Visual Studio 2010
Precompiled FFTW 3.3.1 Windows DLLs install using fftw-3.2.1-dll.zip, on my Windows XP machine.
Open cmd window and go to lib.exe folder C:\Program Files\Microsoft Visual Studio 10.0\VC\bin>
Type lib /def:libfftw3-3.def
Type lib /def:libfftw3f-3.def
Type lib /def:libfftw3l-3.def
If you have a error on command, copy any mspdb80.dll or mspdb100.dll file to in bin directory.
You will get 6 files
libfftw3-3.exp, libfftw3-3.lib, libfftw3f-3.exp, libfftw3f-3.lib,
libfftw3l-3.exp and libfftw3l-3.lib
and copy it to programming directory.
Delete all mspdb80.dll or mspdb100.dll file from bin directory.
Closed Project and open again and rebuild it again.
Have you actually linked against the library in the project you're building?
Project -> Properties -> Linker -> Input -> Additional dependencies
You need to add the library's filename to that field.
Assuming you've actually linked your project against the lib and it doesn't work, use /verbose:lib and paste the output of that and the output of
dumpbin /exports fftw.lib | findstr fftw_free
I had similar problem. What helped was compiling the fftw libs with this help Compiling FFTW source in Visual studio. Actually more closely the problem was compiling my application Win 32 and trying to use x64 -libraries. So make sure the platform is same.