in my current c++ project I need to use avro c++ serializer. Firstly I built boost 1.6.2 and based on it I build via Visual Studio 2015 the Avro-cpp.sln file as it is mentioned in avro relevant site. In my code I'm using the following include files
#include "avro/DataFile.hh"
#include "avro/Compiler.hh"
#include "avro/ValidSchema.hh"
#include "avro/Schema.hh"
#include "avro/Generic.hh"
#include "avro/Specific.hh"
However when I'm trying to build the project I get the following errors
error LNK2019: unresolved external symbol "public: void __thiscall avro::DataFileWriterBase::syncIfNeeded(void)
error LNK2019: unresolved external symbol "public: __thiscall avro::DataFileWriterBase::DataFileWriterBase(char const *,class avro::ValidSchema const &,unsigned int,enum avro::Codec)"
error LNK2019: unresolved external symbol "public: __thiscall avro::DataFileWriterBase::~DataFileWriterBase(void)" (??1DataFileWriterBase#avro##QAE#XZ) referenced in function "public: void * __thiscall avro::DataFileWriterBase::`scalar deleting destructor'(unsigned int)"
error LNK2019: unresolved external symbol "public: void __thiscall avro::DataFileWriterBase::close(void)"
error LNK2019: unresolved external symbol "public: void __thiscall avro::DataFileWriterBase::close(void)"
error LNK2019: unresolved external symbol "void __cdecl avro::compileJsonSchema(class std::basic_istream<char,struct std::char_traits<char> > &,class avro::ValidSchema &)"
error LNK2019: "public: void __thiscall avro::DataFileWriterBase::flush(void)"
I assume that the linker does not find the definition of the the specific classes DataFileWriterBase and compileJsonSchema .Since I'haven't worked with AVRO before I'd like to ask what libraries should I add in order for this problem to be solved? Do I have to insert the relevant cc files in my source code? I also built from Avro-cpp.sln file the avrocpp.dll and the avrocpp_s.dll, included them in my project but the problem remained the same. Does anyone has any idea since I haven't found any hint in either avro site or similar forums.
Hi again these are the new findings
I searched thoroughly and I probably found a possible cause , but I don't know how to move on. The problem seems to be in file Config.hh
#ifndef avro_Config_hh
#define avro_Config_hh
// Windows DLL suport
#ifdef _WIN32
#pragma warning (disable: 4275 4251)
#if defined(AVRO_DYN_LINK)
#ifdef AVRO_SOURCE
# define AVRO_DECL __declspec(dllexport)
#else
# define AVRO_DECL __declspec(dllimport)
#endif // AVRO_SOURCE
#endif // AVRO_DYN_LINK
#endif // _WIN32
#ifndef AVRO_DECL
#define AVRO_DECL
#endif
#endif
I think that AVRO_DYN_LINK is not defined and __declspec(dllexport) is not executed. So AVRO_DECL is defined and even though library lib is build with the function definitions they are exported and the error occur. Do you have any hint on the above analysis?
Related
I am currently upgrading our source code from VS2012 to VS2019. One project which uses MFC does not link successfully:
fatal error LNK1120: 4 unresolved externals
error LNK2001: unresolved external symbol "public: void * __cdecl ATL::IAtlMemMgr::Allocate(unsigned __int64)" referenced in function "public: virtual struct ATL::CStringData * __cdecl ATL::CAtlStringMgr::Allocate(int,int)"
error LNK2001: unresolved external symbol "public: void __cdecl ATL::IAtlMemMgr::Free(void *)" referenced in function "public: virtual void __cdecl ATL::CAtlStringMgr::Free(struct ATL::CStringData *)"
error LNK2001: unresolved external symbol "public: void * __cdecl ATL::IAtlMemMgr::Reallocate(void *,unsigned __int64)" referenced in function "public: virtual struct ATL::CStringData * __cdecl ATL::CAtlStringMgr::Reallocate(struct ATL::CStringData *,int,int)"
error LNK2001: unresolved external symbol "public: virtual struct ATL::CStringData * __cdecl ATL::IAtlStringMgr::Reallocate(struct ATL::CStringData *,int,int)"
We are building with Multi-Byte Character Set (MBCS). My first thought was, that we are missing the the mbcs libraries. But as mentioned here, the libraries are installed by default, "when you select MFC and ATL support".
I added atlbase.h in the code and added atls.lib manually as additional dependency, but that did not solve the problem.
How can I figure out which library is missing?
Edit 1:
Let's take a look into atlmem.h:
__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0")) IAtlMemMgr{
public:
_Ret_maybenull_ _Post_writable_byte_size_(nBytes) void* Allocate(_In_ size_t nBytes) throw();
As far as I see, this is one of the symbols which is not found. As can be red about the __interface keyword, it implicitly makes the functions pure virtual. These kind of linker errors might be caused by non pure virtual function declarations.
Might there be a bug which makes the functions in the __interface not pure virtual?
After excluding nearly all source files and commenting out a lot of functionality, I could see that the linker errors are correlated to <afxwin.h>. Moving <afxwin.h> to the top of each source files removed the linker errors.
However, I am interested to know why compiling with VS2012 gives another behavior compared to VS2019.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a problem I can't get rid off.
I have a small private project where I want to use asio for network communication and boost threads. I don't wan`t install boost on my machine, so I integrated the sourcecode in my project. For that I created a global header including boost thread and asio, like this:
#include "boost/asio.hpp"
#include "boost/thread.hpp"
This way I can build static libs without problems, but shared libs or executables cause linker errors:
error LNK2019: unresolved external symbol "private: bool __cdecl boost::thread::join_noexcept(void)" (?join_noexcept#thread#boost##AEAA_NXZ) referenced in function "public: void __cdecl boost::thread::join(void)" (?join#thread#boost##QEAAXXZ)
error LNK2019: unresolved external symbol "class boost::thread::id __cdecl boost::this_thread::get_id(void)" (?get_id#this_thread#boost##YA?AVid#thread#2#XZ) referenced in function "public: void __cdecl boost::thread::join(void)" (?join#thread#boost##QEAAXXZ)
error LNK2019: unresolved external symbol "public: class boost::thread::id __cdecl boost::thread::get_id(void)const " (?get_id#thread#boost##QEBA?AVid#12#XZ) referenced in function "public: void __cdecl boost::thread::join(void)" (?join#thread#boost##QEAAXXZ)
error LNK2019: unresolved external symbol "private: bool __cdecl boost::thread::do_try_join_until_noexcept(unsigned __int64,bool &)" (?do_try_join_until_noexcept#thread#boost##AEAA_N_KAEA_N#Z) referenced in function "private: bool __cdecl boost::thread::do_try_join_until(unsigned __int64)" (?do_try_join_until#thread#boost##AEAA_N_K#Z)
error LNK2019: unresolved external symbol "public: void __cdecl boost::thread::interrupt(void)" (?interrupt#thread#boost##QEAAXXZ) referenced in function "public: __cdecl NetworkAdapter::~NetworkAdapter(void)" (??1NetworkAdapter##QEAA#XZ)
error LNK2019: unresolved external symbol "public: bool __cdecl boost::thread::joinable(void)const " (?joinable#thread#boost##QEBA_NXZ) referenced in function "public: __cdecl NetworkAdapter::~NetworkAdapter(void)" (??1NetworkAdapter##QEAA#XZ)
The current configuration for using boost as source within project so far is:
#define BOOST_SYSTEM_SOURCE
#define BOOST_DATE_TIME_NO_LIB
#define BOOST_REGEX_NO_LIB
#define BOOST_THREAD_DYN_LINK
#define BOOST_THREAD_DYN_DLL
#define BOOST_THREAD_BUILD_DLL
#define BOOST_CHRONO_HEADER_ONLY
#define BOOST_DATE_TIME_NO_LIB
Without this configuration linker asks for *.lib files for thread, chrono and so on.
According to boost homepage Thread and Asio are HeaderOnly, so why is the linker looking for lib, missing symbols - instead of using headers?
So what am I doing wrong?
Appreciating every hint :-)
Best regards,
Dan
From the boost threading website
Boost.Thread depends on some non header-only libraries.
Boost.System: This dependency is mandatory and you will need to link
with the library. Boost.Chrono: This dependency is optional (see below
how to configure) and you will need to link with the library if you
use some of the time related interfaces. Boost.DateTime: This
dependency is mandatory, but even if Boost.DateTime is a non
header-only library Boost.Thread uses only parts that are header-only,
so in principle you should not need to link with the library.
So you're mistaken - it's not header only.
I am having difficulty figuring out my unresolved external errors.
I have 2 different solutions that both share a core project. Solution #1 is called SnapGame and Solution #2 is called SnapEditor. The core project is called SnapCore.
My SnapGame solution is a Win32 application. It compiles, references, and links the SnapCore project with no issues.
The SnapEditor solution is a Windows Forms Application. It compiles and references the SnapCore project. However, it will not link with it properly. I get unresolved external errors any time I try to reference anything from the SnapCore project.
The SnapCore project has some GDI+ support classes. All classes in the SnapCore project are under the SnapCore namespace.
Here is the file Form1.cpp:
#include "stdafx.h"
#include "App.h"
#include "Orient.h"
using namespace SnapCore;
using namespace SnapEdit;
void Form1::Init()
{
SnapCore::Orient orient;
new App();
}
Here are the linker errors I get:
1>Form1.obj : warning LNK4248: unresolved typeref token (01000049) for 'Gdiplus.GpCachedBitmap'; image may not run
1>Form1.obj : error LNK2028: unresolved token (0A000019) "public: __clrcall SnapCore::App::App(void)" (??0App#SnapCore##$$FQAM#XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore#Form1#SnapEdit##$$FQ$AAMXXZ)
1>Form1.obj : error LNK2028: unresolved token (0A00001A) "public: __clrcall SnapCore::Orient::Orient(void)" (??0Orient#SnapCore##$$FQAM#XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore#Form1#SnapEdit##$$FQ$AAMXXZ)
1>Form1.obj : error LNK2019: unresolved external symbol "public: __clrcall SnapCore::App::App(void)" (??0App#SnapCore##$$FQAM#XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore#Form1#SnapEdit##$$FQ$AAMXXZ)
1>Form1.obj : error LNK2019: unresolved external symbol "public: __clrcall SnapCore::Orient::Orient(void)" (??0Orient#SnapCore##$$FQAM#XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore#Form1#SnapEdit##$$FQ$AAMXXZ)
1>C:\Work\PC\SnapEdit\SnapEdit\Debug\SnapEdit.exe : fatal error LNK1120: 4 unresolved externals
I can't figure out why my SnapGame solution links with no troubles, but the SnapEditor solution will not.
Any help would be appreciated.
If I understand you right, SnapEditor is a managed application. It can't simply refer to a native library, like SnapCore. Use P/Invoke, or write a managed wrapper.
I'm back to C/C++ after some break.
I've a following problem:
I've a solution where I've several projects (compilable and linkable).
Now I need to add another project to this solution which depends on some sources from other projects.
My new project compiles without any problems (I've added "existing sources" to my project).
the error:
1>Linking...
1>LicenceManager.obj : error LNK2019: unresolved external symbol "int __cdecl saveLic(char *,struct Auth *)" (?saveLic##YAHPADPAUAuth###Z) referenced in function "public: void __thiscall LicenceManager::generateLicence(int,char *)" (?generateLicence#LicenceManager##QAEXHPAD#Z)
1>LicenceManager.obj : error LNK2019: unresolved external symbol "void __cdecl getSysInfo(struct Auth *)" (?getSysInfo##YAXPAUAuth###Z) referenced in function "public: void __thiscall LicenceManager::generateLicence(int,char *)" (?generateLicence#LicenceManager##QAEXHPAD#Z)
Functions saveLic, and getSysInfo are defined in files which I've added to my new project from existing ones. There is object file created during compilation with those functions in target dir, but my LicenceManager class doesn't want to link.
I use some
extern "C" , and #pragma pack
somewhere, but no more fancy stuff. I think every directory, lib and other necessary dependencies are visible in settings for this project.
Thanks for any advice.
Seems like you need to make sure the functions are declared properly as C functions:
#ifdef __cplusplus
extern "C" {
#endif
int saveLic(char *,struct Auth *);
void getSysInfo(struct Auth *);
#ifdef __cplusplus
}
#endif
In a header file included by LicenceManager.cpp.
I am using Visual C++ 2005 Express Edition and get the following linker errors:
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise#exception#std##QBEXXZ) referenced in function "protected: static void __cdecl std::vector<class mytype,class std::allocator<class mytype> >::_Xlen(void)" (?_Xlen#?$vector#Vmytype##V?$allocator#Vmytype###std###std##KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise#exception#std##QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception#std##QAE#PBDH#Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error#std##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##1##Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception#std##QAE#PBDH#Z)
I turned off exceptions in generated code, and I am using before including the vector header file:
#define _HAS_EXCEPTIONS 0
A few Google results turned up some stuff, but no "aha!" solutions that worked for me.
EDIT:
As noted "_HAS_EXCEPTIONS 0" doesn't turn off exceptions, per se. What it does is, at least in the vector header file, is call _Raise on an exception object instead of calling the C++ "throw". In my case, it can't link to the exception object's _Raise function since I am not including the correct library. What that library is, though, is not obvious.
Adding this line:
#define _STATIC_CPPLIB
before including the vector header seems to do the trick.
The third error makes it clear that #define the _HAS_EXCEPTIONS 0 does not affect . Now, might include (makes sense, sharing code might reduce the size of your executable). That would explain why you still have errors if you define it before your inclusion of . This kind of defines should be done in your project settings.
Note that _HAS_EXCEPTIONS is an unsupported feature in Visual Studio. It does not turn off exceptions as such.