Boost-log linker error - c++

i've downloaded and builded Boost 1.55 from source. I'm trying to use Boost-log. In basic case (http://boost-log.sourceforge.net/libs/log/doc/html)/log/tutorial.html#log.tutorial.trivial it's working fine without any problems, but when i try to use some more advanced features(like this - http://boost-log.sourceforge.net/libs/log/example/doc/tutorial_fmt_stream.cpp ) i'm getting this error:
main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::filesystem::path_traits::convert(char const *,char const
*,class std::basic_string,class std::allocator>
&,class std::codecvt const &)" (?convert#path_traits#filesystem#boost##YAXPBD0AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##ABV?$codecvt#GDH#5##Z)
referenced in function "void __cdecl
boost::filesystem::path_traits::dispatch,class std::allocator > >(class
std::basic_string,class
std::allocator > const &,class std::basic_string,class
std::allocator > &,class std::codecvt const &)"
(??$dispatch#V?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std###path_traits#filesystem#boost##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##4#ABV?$codecvt#GDH#4##Z)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::log::v2s_mt_nt5::aux::code_convert(unsigned short const
*,unsigned int,class std::basic_string,class std::allocator > &,class
std::locale const &)"
(?code_convert#aux#v2s_mt_nt5#log#boost##YAXPBGIAAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABVlocale#6##Z)
referenced in function "private: void __thiscall
boost::log::v2s_mt_nt5::basic_formatting_ostream,class std::allocator>
::aligned_write(unsigned short const *,__int64)" (??$aligned_write#G#?$basic_formatting_ostream#DU?$char_traits#D#std##V?$allocator#D#2##v2s_mt_nt5#log#boost##AAEXPBG_J#Z)
1>main.obj : error LNK2019: unresolved external symbol "public: static
class std::codecvt const & __cdecl
boost::filesystem::path::codecvt(void)"
(?codecvt#path#filesystem#boost##SAABV?$codecvt#GDH#std##XZ)
referenced in function "public: __thiscall
boost::filesystem::path::path(char const (&)[14],void
*)" (??$?0$$BY0O#$$CBD#path#filesystem#boost##QAE#AAY0O#$$CBDPAX#Z)
So basically it can't find functions convert(...), code_convert(...) and codecvt(...) in .lib files.
I've already tried to add all release libraries (.lib files made while building boost) to "additional libraries" and generally i think that visual studio find all libraries, but can't find those functions in libraries. Any ideas how can i fix this?
I've build Boost 1.55 from source using visual studio 2010 (msvc10.0), 32 bit, release and debug. I'm working on windows 7 x64.

I had the same problem and I could fix it by changing one of the Project properties on VisualStudio 2010.
Go to:
Property Pages -> ConfigurationProperties -> C/C++ -> Language -> Treat WChar_t As Built in Type:
And set the property to:
Yes (/Zc:wchar_t)
I hope it will be helpful for you too :)
Take care,

Related

Error building c++ project with ppconsul(Consul client for c++)

I'm a beginner to cpp and trying to use a cpp library called ppconsul(https://github.com/oliora/ppconsul ). This library has dependency to some of other libraries like (boost and curl). I have build ppconsul with all its dependencies and trying to use ppconsul executable in a new project. When I try to build the new project, I'm getting some linker issue like below.
error LNK2001: unresolved external symbol "public: virtual char const * thiscall ppconsul::BadStatus::what(void)const " (?what#BadStatus#ppconsul##UBEPBDXZ)
1>ConsulApp.obj : error LNK2019: unresolved external symbol "class std::basic_string,class std::allocator > __cdecl ppconsul::helpers::encodeUrl(class std::basic_string,class std::allocator > const &)" (?encodeUrl#helpers#ppconsul##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV34##Z) referenced in function "void __cdecl ppconsul::parameters::detail::printParameter(class std::basic_ostream > &,class std::basic_string,class std::allocator > const &,struct ppconsul::kw::dc_keyword)" (??$printParameter#Udc_keyword__#kw#ppconsul###detail#parameters#ppconsul##YAXAAV?$basic_ostream#DU?$char_traits#D#std###std##ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##4#Udc_keyword__#kw#2##Z)
I tried to link the project and change the visual studio but nothing worked. Anybody has any idea about this linker issue?
TIA,
Prassi
Issue resolved- Refer this thread github.com/oliora/ppconsul/issues/24
build ppconsul as a static library by passing -DBUILD_STATIC_LIB=ON to CMake.

Errors on running a sample PCL code on Visual Studio 2017

I'm trying to run a sample PCL code just to start developing PCL on Visual Studio (2017) on my Windows 10. I followed the guides here: http://dominoc925.blogspot.com/2016/07/set-up-visual-studio-to-use-all-in-one.html
As suggested in their blog post, I downloaded the all-in-one 64bit installer from here: https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.8.1rc1
While I followed all steps, they didn't have a link to a property sheet for PCL 1.8.1 (where can I find it?)
Anyways, when I try to compile my project (no errors on editor), I get 3 link errors as below. How can I run a sample PCL code in Visual Studio? Please help.
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const *,...)" (?print#console#pcl##YAXW4VERBOSITY_LEVEL#12#PEBDZZ) referenced in function "public: void __cdecl pcl::detail::FieldMapper<struct pcl::PointXYZ>::operator()<struct pcl::fields::x>(void)" (??$?RUx#fields#pcl###?$FieldMapper#UPointXYZ#pcl###detail#pcl##QEAAXXZ) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::readHeader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int &,unsigned int &,int)" (?readHeader#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAH4AEAIH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int)" (?read#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAHH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK1120 3 unresolved externals PCLViewer c:\users\xxx\documents\visual studio 2017\Projects\PCLViewer\x64\Debug\PCLViewer.exe 1

I can't compile a solution due to "Error LNK2028: unresolved token..."

I have a dll programmed in C++, and a exe programmed in Visual C++.
I have the functions in dll declared as:
string __declspec( dllexport ) ConfigureHAT(T_STRING pathFile);
And in the exe project I include all the headers files and the dll file.
I call the function in dll:
string ret = ConfigureHAT("file.txt");
And when the executable project is compiled, it fails with the next errors:
1>HATdllTester.obj : error LNK2028: unresolved token (0A000317) "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>AssemblyInfo.obj : error LNK2028: unresolved token (0A000316) "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>AssemblyInfo.obj : error LNK2019: unresolved external symbol "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
referenced in function "private: void __clrcall
HATdllTester::mainWindow::buttonConfigure_Click(class System::Object
^,class System::EventArgs ^)"
(?buttonConfigure_Click#mainWindow#HATdllTester##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>HATdllTester.obj : error LNK2001: unresolved external symbol "class
std::basic_string,class
std::allocator > __cdecl ConfigureHAT(class
std::basic_string,class
std::allocator >)"
(?ConfigureHAT##$$FYA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V12##Z)
Can anybody help me?
I read a lot of similar messages with the same error, but no one solves my problem.
Thanks.
EDIT
Finally, I solve the problem including the .lib file generated in the dll project into Project Properties -> Linker -> Input -> Additional Dependencies.
I'd try changing Visual Studio project configuration. Under General > Common Language Runtime Support set /clr instead of /clr:pure.
This helped me when I changed CLR MyProjectCLR.vcxproj project file and added a link to C MyProjectC.vcxproj project
<ItemGroup>
<ProjectReference Include=".\MyProjectC.csproj">
<Project>{f6ead438-e6cf-4df6-b2f4-d33d533c5343}</Project>
</ProjectReference>
</ItemGroup>

Mixing native C++ and C++/CLI

I have a solution which consists of a native C++ DLL and a C++/CLI wrapper. My aim is to create a wrapper in C++/CLI of the native C++ DLL.
Whenever I try to create an instance of a native C++ class within the wrapper, I am met with many linker errors (see below).
2> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
2>NFileOperation.obj : error LNK2028: unresolved token (0A000208) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "[T2M] void __clrcall `dynamic initializer for 'public: static float * tagVARIANT::* ATL::CVarTypeInfo<float *>::pmField''(void)" (__t2m#???__E?pmField#?$CVarTypeInfo#PAM#ATL##2QQtagVARIANT##PAMQ3###YMXXZ#?A0x22b777aa##YMXXZ)
2>DeskUpdateManaged.obj : error LNK2028: unresolved token (0A00021C) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" (?FileExist#Conversion#DeskUpdateManaged##$$FQ$AAM_NP$AAVString#System###Z)
2>DeskUpdateManaged.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" (?FileExist#Conversion#DeskUpdateManaged##$$FQ$AAM_NP$AAVString#System###Z)
2>NFileOperation.obj : error LNK2001: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z)
2>C:\Users\ABGZAMANK\Music\DeskUpdate\Dev\Source\Solution\Debug\DeskUpdateManaged.dll : fatal error LNK1120: 3 unresolved externals
Function call within the C++/CLI to the native C++ DLL:
bool NFileOperation::FileExists(CAtlString sPathName)
{
return CFileOperation::FileExists(sPathName);
}
Is there a more adequate approach to what I am trying to achieve?
Any advice relating to the issue is much appreciated.
It seems that your native C++ code is using ATL/MFC. Assuming you are compiling under VS, go to the C++/CLI project's project properties->Configuration properties->General and select "Use of MFC" and "Use of ATL" to be either static library or shared dll (depending on your project type). This flag will add the necessary include paths, linking paths and libs to your project to make use of ATL/MFC types from within your project. Also, make sure that you are linking your C++/CLI project against your native C++ project to avoid linking errors from your project (easily found in the Linker segment of the project properties in General and Input).

Linking error while using Visual Studio 2005(VC8)

I am getting a bunch of linking errors while trying to link the release version of an executable(debug version does not have the same issue). Comparing the command line for the link does not reveal any issues.
there are broadly 2 types of errors neither of which I can get a handle on.
The first kind complains about a unresolved external symbol _declspec(dllimport)
As an example:
error LNK2019: unresolved external symbol
"_declspec(dllimport)
public: __thiscall
stlpd_std::basic_string,class stlpd_std::allocator >::basic_string,class stlpd_std::allocator >(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z)
for a more human readable version(replacing all the strings):
error LNK2019: unresolved external symbol
"__declspec(dllimport)
public: __thiscall
string::basic_string,class stlpd_std::allocator >(class string const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class string const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z
The sceond class of errors complains about
unresolved external symbol __CrtDbgReportW
I hope I can get some kind of insight in dealing with this.
From the errors it looks like you are not including the CRT as one of your linked libraries. Here is a link to the different CRT lib's offered in Visual Studio 2005. Choose the one which is most appropriate and make sure it's in the list of lib's to link against
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx
It looks like you're either including a file that's been built using the debug settings or you're mixing runtime libraries (DLL and static).