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.
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.
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?
I'm having a really hard time trying to figure out how to build Google's V8 on Windows.
So far I have:
Installed depot_tools
Fetched v8: fetch v8
Created the project files: gn gen --ide=vs2015 out/Default
Built the entire solution in VS2015
My issue is that this only produces a large number of .obj files and no .lib files.
I have set the projects (v8, v8_base, v8_libbase, etc.) to Configuration type: Static library (.lib):
I'm not sure how to get Visual Studio to generate the library files. Any help appreciated!
Update
I have managed to produce library files using the following steps:
Open VS Developer Command Line
Navigate to the directories containing obj files for v8_base, v8_libbase, v8_external_snapshot and v8_libplatform.
For each of these, build a .lib manually using the lib command e.g. lib /o:v8_base *.obj
Copy all these lib files into a directory along with icui18n.lib and icuuc.lib (these were created fine during the build.)
I'm now trying to actually use the libraries and have a new problem which I would appreciate help with.
I have linked the following libraries in VS: v8_base.lib; v8_libbase.lib; v8_external_snapshot.lib; v8_libplatform.lib; icui18n.lib; icuuc.lib; winmm.lib;, however I am having an issue with a few unresolved symbols:
unresolved external symbol "public: static void __cdecl v8::sampler::Sampler::TearDown(void)" (?TearDown#Sampler#sampler#v8##SAXXZ) referenced in function "public: static void __cdecl v8::internal::V8::TearDown(void)" (?TearDown#V8#internal#v8##SAXXZ) TriviaBot v8_base.lib(v8.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Stop(void)" (?Stop#Sampler#sampler#v8##QEAAXXZ) referenced in function "private: void __cdecl v8::internal::Isolate::Deinit(void)" (?Deinit#Isolate#internal#v8##AEAAXXZ) v8_base.lib(isolate.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Stop(void)" (?Stop#Sampler#sampler#v8##QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: __cdecl v8::sampler::Sampler::Sampler(class v8::Isolate *)" (??0Sampler#sampler#v8##QEAA#PEAVIsolate#2##Z) referenced in function "public: __cdecl v8::internal::Ticker::Ticker(class v8::internal::Isolate *,int)" (??0Ticker#internal#v8##QEAA#PEAVIsolate#12#H#Z) v8_base.lib(log.obj)
unresolved external symbol "public: __cdecl v8::sampler::Sampler::Sampler(class v8::Isolate *)" (??0Sampler#sampler#v8##QEAA#PEAVIsolate#2##Z) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: virtual __cdecl v8::sampler::Sampler::~Sampler(void)" (??1Sampler#sampler#v8##UEAA#XZ) referenced in function "public: virtual void * __cdecl v8::internal::Ticker::`scalar deleting destructor'(unsigned int)" (??_GTicker#internal#v8##UEAAPEAXI#Z)
unresolved external symbol "public: virtual __cdecl v8::sampler::Sampler::~Sampler(void)" (??1Sampler#sampler#v8##UEAA#XZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::Start(void)" (?Start#Sampler#sampler#v8##QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Engage(void)" (?Engage#Profiler#internal#v8##QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::IncreaseProfilingDepth(void)" (?IncreaseProfilingDepth#Sampler#sampler#v8##QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Engage(void)" (?Engage#Profiler#internal#v8##QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::IncreaseProfilingDepth(void)" (?IncreaseProfilingDepth#Sampler#sampler#v8##QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DecreaseProfilingDepth(void)" (?DecreaseProfilingDepth#Sampler#sampler#v8##QEAAXXZ) referenced in function "public: void __cdecl v8::internal::Profiler::Disengage(void)" (?Disengage#Profiler#internal#v8##QEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DecreaseProfilingDepth(void)" (?DecreaseProfilingDepth#Sampler#sampler#v8##QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DoSample(void)" (?DoSample#Sampler#sampler#v8##QEAAXXZ) referenced in function "public: virtual void __cdecl v8::internal::SamplingThread::Run(void)" (?Run#SamplingThread#internal#v8##UEAAXXZ) v8_base.lib(log.obj)
unresolved external symbol "public: void __cdecl v8::sampler::Sampler::DoSample(void)" (?DoSample#Sampler#sampler#v8##QEAAXXZ) v8_base.lib(cpu-profiler.obj)
unresolved external symbol "public: static void __cdecl v8::sampler::Sampler::SetUp(void)" (?SetUp#Sampler#sampler#v8##SAXXZ) referenced in function "private: static void __cdecl v8::internal::V8::InitializeOncePerProcessImpl(void)" (?InitializeOncePerProcessImpl#V8#internal#v8##CAXXZ) v8_base.lib(v8.obj)
All of the error seem to be related to v8::sampler - any help is again appreciated!
And it looks like I'm answering my own question again. I hope the info I listed in the question will be useful for anyone who struggles with the out-of-date documentation like me.
My update covers everything required except for the fact I didn't even notice the v8_libsampler project and forgot to generate the library file for it. Once I did that and linked it, I was up and running!
Just like you, I was trying different settings to get the lib building. And here are my steps:
After gn gen, run gn args out/Default, uncomment is_component_build, that's the equivalent of component=shared_library I guess.
While I also have problem building all.sln in vs.net I realized msbuild can give me some of the dll/lib files.
Good luck.
I have done similar config but for VS2013 and runned ninja to build everything. Build has produced me set of DLLs, including v8.dll, which I am completely fine with.
I have a third party libs. (msvc10) a MT/MD (Static cfgs's) and dynamic DLL cfg.
I have qt + msvc10 express + win sdk.7
Ok , I use the existing examples offered, (using the libs) I can't compile ..... I have 4 unresolved external errors of the same lib.
(But I have zero errors for the others)
I have not support for these lib...... (but they are legal, I am a member without rights)
Which are the steps to investigate a possible fix? Where I have to look ?
Thanks.
Edit 1:
The errors was:
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueW#32 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey#4 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExW#24 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExW#20 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
..\exe\OdaQtApp.exe : fatal error LNK1120: 13 unresolved externals
During this post I have received a solution: I have to link with Advapi32.lib...
My question is : how can I know this ?
I have tried the dependencyywalker, but it cant use the .lib's....
During this post I have received a solution: I have to link with Advapi32.lib... My question is : how can I know this?
When you get an "unresolved external" error from the linker, that means that it was looking for a match for a function or variable name that some object file needs and the linker was unable to find that name defined in one of the object files or libraries.
Start by looking at the first of these errors (I've reformatted it a bit to make it slightly more readable - I encourage yo to do the same next time you come across one of these):
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol
__imp__RegEnumValueW#32 referenced in function
"public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(
class OdTtfDescriptor const &,class OdString &)"
(?ttfFileNameByDescriptor#ExHostAppServices##UAE_N ABVOdTtfDescriptor##AAVOdString###Z)
There's a lot of stuff in that error message (much of it may look like garbage). Fortunately, much of it can be ignored in most cases. The most important item is that the linker is looking for the symbol __imp__RegEnumValueW#32 The name has some gunk on it, but fortunately it's pretty recognizable anyway.
the __imp__ prefix indicates it's looking for a DLL import. In nearly all cases that can be ignored for your purposes.
the #32 suffix is something the Microsoft compiler adds to function names for certain calling conventions. It's also generally not important for your purposes (for the record it indicates that the function expects 32 bytes of argument data)
So we're left with the fact that the linker is looking for RegEnumValueW. That looks a lot like the name of a Win32 API.
If you look at the docs for RegEnumValueW (or RegEnumValue, since many Win32 APIs have both an A and a W variant to handle ANSI/UNICODE builds) we'll find in the documentation this bit of information:
Requirements
Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header Winreg.h (include Windows.h)
>> Library Advapi32.lib
DLL Advapi32.dll
Unicode and ANSI names RegEnumValueW (Unicode) and
RegEnumValueA (ANSI)
That's how you know you need advapi32.lib.
So in the future, when you get an "unresolved external" error from the linker, just ignore most of the gunk in the error message and concentrate on the symbol it says it can't find - that should lead you to the library, object file or other item you might be missing.
Just for the record, advapi32.lib will be needed by most Windows applications of any complexity.
you can try to use dependencywalker to see the list of dependencies for your dlls and see what it's missing.
have you entered the *.lib file in the linker options? (input --> additional dependencies"), and in addition the path to the .lib in libraries directories option?
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.