unresolved symbols from boost filesystem - c++

I am using boost 1_53 libraries with VS10.
I am getting many unresolved symbols during linking. like the following:
error LNK2019: unresolved external symbol "void __cdecl boost_1_53_0::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &,class std::codecvt<unsigned short,char,int> const &)" (?convert#path_traits#filesystem#boost_1_53_0##YAXPEBD0AEAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##AEBV?$codecvt#GDH#5##Z) referenced in function "void __cdecl boost_1_53_0::filesystem::path_traits::convert(char const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &,class std::codecvt<unsigned short,char,int> const &)" (?convert#path_traits#filesystem#boost_1_53_0##YAXPEBDAEAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##AEBV?$codecvt#GDH#5##Z)
I checked /LIBPATH is set correctly also "boost_1_53_0_filesystem-mt.lib" is coming in link line.
i used dumpbin to find symbol in "lib" its coming like:
00000036 REL32 00000000 515 ?convert#path_traits#filesystem#boost_1_53_0##YAXPEBD0AEAV?$basic_string#_WU?$char_traits#_W#std##V?$allocator#_W#2##std##AEBV?$codecvt#_WDH#5##Z (void __cdecl boost_1_53_0::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &))
Is this parameter change causing issue?
EDIT:
I like to add more details:
Previously i was using boost 1_48 which was working fine.
I found that in boost 1_48 symbols under path_traits ends with #GDH#5##Z whicle in boost 1_53 its ending with #_WDH#5##Z
But still It trying to search synbol end with #GDH#5##Z
This can cause error?
If so why its taking that symbols?

Unless you've built every possible permutation of the Boost libraries, it is necessary to make sure that your compiler settings match the settings used to build Boost.
The relevant settings are:
debug vs. release
statically linked runtime vs. DLL
single-threaded vs. multi-threaded
The name boost_1_53_0_filesystem-mt.lib implies that the Boost libraries were built release mode, multi-threaded, DLL runtime.
Is that how you're building your project?

Right click on
->properties
->in general tab
check whether
Common Language Runtime support = "No Common Language Runtime support"
-> in c/C++ -> code generation
check whether
Runtime library Multi-threaded DLL (/MD)
finally in the menu bar go to
-> tools -> options -> project and solutions -> VC++ directories -> library files
check whether you have given the complete path where you boost librarus are usually
"\boost_1_53\stage\lib"
NOTE: the setting paths are mentioned for VS2008

You can check if you are not using 64 bit compiled boost libraries instead of 32 bit ones (and vice versa). It's what happened for me while using boost::filesystem.

Related

unresolved external using fmt::format to return std::wstring

I am using fmt 7.1.3 with Visual Studio 2019.
I take the fmt src files and make a static lib.
When I link this lib into an exe project that does:
std::wstring out = fmt::format(L"Answer {}", 42);
It compiles but fails with a linker error:
unresolved external symbol "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl fmt::v7::detail::vformat<wchar_t,0>(class fmt::v7::basic_string_view<wchar_t>,class fmt::v7::basic_format_args<class fmt::v7::basic_format_context<class fmt::v7::detail::buffer_appender<wchar_t>,wchar_t> >)" (??$vformat#_W$0A##detail#v7#fmt##YA?AV?$basic_string#_WU?$char_traits#_W#std##V?$allocator#_W#2##std##V?$basic_string_view#_W#12#V?$basic_format_args#V?$basic_format_context#V?$buffer_appender#_W#detail#v7#fmt##_W#v7#fmt###12##Z) referenced in function "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl fmt::v7::format<wchar_t [10],int,wchar_t>(wchar_t const (&)[10],int &&)"
The same static lib configuration works fine if I use the src from fmt-6.2.1.
Thanks for your help.
Make sure to include fmt/format.h where this function is defined. Quoting the docs:
fmt/format.h: the full format API providing compile-time format string checks, wide string, output iterator and user-defined type support
Here is a working example on godbolt.

Linking to OCCI libs generates warnings about std::string

I have created a Static Library project (sll) which is using the std::string. Then I linked it to oraocci12.lib (for release) and oraocci12d.lib (for debug). And just upon linking the static library to the OCCI ones the project generates many warnings about std::string. The warnings are all about already defined symbols, something like:
warning LNK4006: "public: void __cdecl std::basic_string,class std::allocator >::_Copy(unsigned
__int64,unsigned __int64)" (?_Copy#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QEAAX_K0#Z)
already defined in oraocci12.lib(oraocci12.dll); second definition
ignored
warning LNK4006: "public: char * __cdecl std::_Wrap_alloc >::allocate(unsigned __int64)"
(?allocate#?$_Wrap_alloc#V?$allocator#D#std###std##QEAAPEAD_K#Z)
already defined in oraocci12.lib(oraocci12.dll); second definition
ignored
warning LNK4006: "public: class std::basic_string,class std::allocator > & __cdecl
std::basic_string,class
std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned
__int64,unsigned __int64)" (?assign#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QEAAAEAV12#AEBV12#_K1#Z)
already defined in oraocci12.lib(oraocci12.dll); second definition
ignored
warning LNK4006: "public: class std::basic_string,class std::allocator > & __cdecl
std::basic_string,class
std::allocator >::assign(char const *,unsigned __int64)"
(?assign#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QEAAAEAV12#PEBD_K#Z)
already defined in oraocci12.lib(oraocci12.dll); second definition
ignored
warning LNK4006: "public: class std::basic_string,class std::allocator > & __cdecl
std::basic_string,class
std::allocator >::erase(unsigned __int64,unsigned __int64)"
(?erase#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QEAAAEAV12#_K0#Z)
already defined in oraocci12.lib(oraocci12.dll); second definition
ignored
warning LNK4006: "`string'"
(??_C#_0BA#JFNIOLAK#string?5too?5long?$AA#) already defined in
oraocci12.lib(oraocci12.dll); second definition ignored
warning LNK4006: "`string'"
(??_C#_0BI#CFPLBAOH#invalid?5string?5position?$AA#) already defined in
oraocci12.lib(oraocci12.dll); second definition ignored
I have tried changing the:
Platform Toolset in Project Properties => General.
Character Set in Project Properties => General.
Runtime Library in Project Properties => C/C++ => Code Generation.
Verbose in Project Properties => Librarian => General.
Ignore All default Libraries in Project Properties => Librarian => General.
Also tried linking to different oracle libs:
msvc\vc14\oraocci12.lib (release)
msvc\vc14\oraocci12d.lib (debug)
msvc\oraocci12.lib (release)
msvc\oraocci12d.lib (debug)
I have also tried many combinations of the above, but the problem persists.
IMP: It happens if the project type is sll. If it is changed to dll, then the warnings go away.
Environment details:
Visual Studio Professional 2017 (15.6.7)
Project Type is Static Library (sll, x64)
Windows 10
Oracle instantclient-sdk-windows.x64-12.2.0.1.0
Thanks all!

C++ IDE migration from VS 6 to VS 2013

A C++ project can be compiled by VS6 without errors&warnings.
With VS 2013 Prof., linker problems are occuring. They are providing a pattern namely std::basic_string.
The code was written in 2007 but not by me.
Referenced by a constructor:
vrun.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: char const * __thiscall
std::basic_string,class
std::allocator >::c_str(void)const " (__imp_?c_str#?$basic_s
tring#DU?$char_traits#D#std##V?$allocator#D#2##std##QBEPBDXZ)
referenced in fun ction "public: __thiscall VTrs::VTrs(class
VMessageContext &)" (?? 0VDMTrs##QAE#AAVVDMMessageHandlerContext###Z)
In vrun.cpp:
VTrs::VTrs(VMessageContext& handler_):
Inherited(RXS::rName().c_str()),
_handler(handler_)
{
}
(c_str -> const char* c_str() const; --- C98 style --- C11 was not applied in the project till yet)
In vrun.h:
VTrs(VMessageContext&);
Referenced by an operator:
vrun.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
public: int __thiscall std::basic_string<char,struct std::char_traits<char>,cl
ass std::allocator<char> >::compare(char const *)const " (__imp_?compare#?$basi
c_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QBEHPBD#Z) referenced in
function "bool __cdecl std::operator==<char,struct std::char_traits<char>,clas
s std::allocator<char> >(class std::basic_string<char,struct std::char_traits<c
har>,class std::allocator<char> > const &,char const *)" (??$?8DU?$char_traits#
D#std##V?$allocator#D#1##std##YA_NABV?$basic_string#DU?$char_traits#D#std##V?$a
llocator#D#2##0#PBD#Z)
Refers -as far as interpreted- to a standard operator. (No operator overloading done for == which refers to a string)
By the way, the code itself does not contain "std::basic_string".
The according msdn article was read but this issue was not resolved till yet.
'Usual' issues such as the "C" modifier modifications are already considered for another code.
Any hint how to cope with that?
EDIT: When opening the project the first time with Visual Studio 2013, a kind of conversion dialog was displayed. I agreed but it affected the VC++ Directories. It was visible when comparing the project file with ClearCase to the previous verison. UndoCheckout (via ClearCase) applied the old state. Now it works.
Your linker needs to get the newer MSVC std library from the relevant lib file and it should pick this up when you migrate the project. Take a look at Project Properties->Configuration Properties->Linker->Input and make sure "Ignore All Default Libraries" is set to No
When opening the project the first time with Visual Studio 2013, a kind of conversion dialog was displayed. I agreed but it affected the VC++ Directories. It was visible when comparing the project file with ClearCase to the previous version. UndoCheckout (via ClearCase) applied the old state. Now it works.

linker error when using Qt and Boost

When I am using Qt (v4.7.4) and Boost (tried v1.47 and v1.48) together in my c++ project, I get a linker error caused by a class that includes <boost\filesystem.hpp>. I just set up Qt and before the code was working without any problems.
This is error message:
...obj : error LNK2001: unresolved external symbol "private: static class std::codecvt const * & __cdecl boost::filesystem3::path::wchar_t_codecvt_facet(void)" (?wchar_t_codecvt_facet#path#filesystem3#boost##CAAAPBV?$codecvt#GDH#std##XZ)
...obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem3::path_traits::convert(char const *,char const *,class std::basic_string,class std::allocator > &,class std::codecvt const &)" (?convert#path_traits#filesystem3#boost##YAXPBD0AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##ABV?$codecvt#GDH#5##Z)
...obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem3::path_traits::dispatch(class boost::filesystem3::directory_entry const &,class std::basic_string,class std::allocator > &,class std::codecvt const &)" (?dispatch#path_traits#filesystem3#boost##YAXABVdirectory_entry#23#AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##ABV?$codecvt#GDH#6##Z)
...obj : error LNK2001: unresolved external symbol "void __cdecl boost::filesystem3::path_traits::convert(unsigned short const *,unsigned short const *,class std::basic_string,class std::allocator > &,class std::codecvt const &)" (?convert#path_traits#filesystem3#boost##YAXPBG0AAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV?$codecvt#GDH#5##Z)
...exe : fatal error LNK1120: 4 unresolved externals
EDIT:
Here I found someone having this problem coming to this conclusion:
this really is a Qt issue. Using wchar_t as a native type you have to
recompile Qt using the same compiler switch. There even is a bug in the
tracker: https://bugreports.qt.io/browse/QTBUG-9617
In general, you will have to be very careful and do not mix wchar_t
compiler settings in your projects as they will become incompatible.
So I recompiled Qt setting /Zc:wchar_t, but it didn't show any effect. I still get the same error.
I think you are on the right track, but it sounds like your -Zc:wchar_t didn't "stick." We had to do the same thing to make Qt happy with Google Breakpad and the ICU library. We changed the /Zc:wchar_t setting in (QT_SOURCE)\mkspecs\win32-msvc2008\qmake.conf and compiled Qt from source, and after that everything works.
When you build your project that uses Qt and Boost, you should see this option in the compiler output. Something like:
cl -c -nologo -Zm200 -Zc:wchar_t ... (etc.)
If you've already build Qt without this option, you may have to do a make confclean first to ensure everything really gets rebuilt with the new settings.
It sounds like -Zc:wchar_t will be the default in Qt 5.
Using boost-1.49, Qt 4.4 and VS2005 had the same problem. Going to project properties, then setting "Configuration Properties -> C/C++ -> Language -> Treat wchar_t as Built-in Type" to "Yes" fixed the problem.
Qt probably changed the tipology of your program with regards the configuration of the runtime: consequently, the boost library you use (filesystem), that come in many configuration accessed by naming convention - connot be found.
For instance, multithread runtimes require mt somewhere in library name (I hope I remember well, but anyway see the docs where details are fully documented). This naming is fairly transparent to the programmer, due to pragmas that boost programmers appropriately used to ease the library usage under different compilers.
You should miss the non-wchar filesystem.lib. When I used Windows, I used boost Jam to interface with Visual C++ (may be that goes back to the past millenium!). I hope it's still usable.

newbie: Determinate CRT lib used by library

I'm developing application using VC++ 6.
I have a 3rd party DLL. This library compiled as Multithreaded DLL (/MD) and my application too.
But I fail to link:
LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /INCREMENTAL:NO specification
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_strin
g#DU?$char_traits#D#std##V?$allocator#D#2##std##QAE#XZ) already defined in XXXApi.lib(CODbg.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<c
har,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QAE#ABV01##Z) already defined in XXXApi.lib(Dictionary.obj)
../../Exes/win2k3_oracle11/XXX.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
From here I see that even though both 3rd library and my code compiled as /MD, there's possibly conflict with old/new iostream beining used.
Is there way to determinate what iostream library old/new is used by 3rd party library?
UPD:
The 3rd party lib is static and not dynamic as I thought before.
The lib is compiled /MD. Dependency Walker works wirh DLLs and not which Libs.
There is dependency Walker, if you don't know this tool.
http://dependencywalker.com/
Drag and drop your DLL or exe on the main window. It will show all dependencies.
And if you want to link to a 3rd party DLL, all you need is a .lib made for that DLL.
If you don't have that .lib, you can always make one using lib.exe or polib.exe from pelles c tools.
polib is easier to use because you don't need to write a .def file.
http://www.smorgasbordet.com/pellesc/
I hope it helps for your question.
Edit: Do you have the source code for the .lib you are using?