Xerces Link error with Visual Studio 2008 - c++

I'm trying to write a code using Xerces, the build worked fine, but when it comes to the link, it fails with the following error:
I'm using Visual Studio 2008 Win32 / with xerces 3 (xerces-c_3.lib) / using Multi-threaded DLL (/MD) and i check that "treat wchar_t as built-in type" is set to yes.....
Have you an idea of where my error could be ?
3>Linking...
3>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
3>signatureinserter.lib(schemeSignatureInserter.obj) : error LNK2001: unresolved external symbol "public: static char * __cdecl xercesc_3_1::XMLString::transcode(unsigned short const * const,class xercesc_3_1::MemoryManager * const)" (?transcode#XMLString#xercesc_3_1##SAPADQBGQAVMemoryManager#2##Z)
3>signatureinserter.lib(schemeSignatureInserter.obj) : error LNK2001: unresolved external symbol "public: static char const * const xercesc_3_1::XMLUni::fgXercescDefaultLocale" (?fgXercescDefaultLocale#XMLUni#xercesc_3_1##2QBDB)
3>signatureinserter.lib(schemeSignatureInserter.obj) : error LNK2001: unresolved external symbol "public: static class xercesc_3_1::MemoryManager * xercesc_3_1::XMLPlatformUtils::fgMemoryManager" (?fgMemoryManager#XMLPlatformUtils#xercesc_3_1##2PAVMemoryManager#2#A)
fatal error LNK1120: 3 unresolved externals

This is a pretty old thread however I came across the same issue.
The solution is to make sure you include the Platform specific code:
#include <xercesc/util/PlatformUtils.hpp>
At least for the current version of the library, xerces-c-3.1.4, this is where those static members are defined.
(not sure about transcode method, possibly in previous versions it was also included there?! In my situation I did not had issues with it)

Related

How should I deal with "Fatal error LNK1120" when I tried to compile Ipopt-3.9.3 in Windows 10 & Visual C++ 2010

all.
I’m compiling Ipopt-3.9.3 in Windows 10 & Visual C++ 2010 Express.
I’ve built the projects of libCoinBlas, libConHSL, libCoinLapack as well as libIpopt, and generated libCoinBlas.lib, libCoinHSL.lib, libCoinLapack.lib as well as libIpopt.lib in the correct paths but with some warnings.
While when I tried to build the projects of IpoptAmplSolver and hs071_cpp, there exists the following fatal errors.
5>  Generating Code...
5> Creating library Release\IpoptAmplSolver.lib and object Release\IpoptAmplSolver.exp
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>Release\IpoptAmplSolver.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
5>------ Rebuild All started: Project: hs071_cpp, Configuration: Release Win32 ------
5>  hs071_main.cpp
5>  hs071_nlp.cpp
5>  Generating Code...
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
5>Release\hs071_cpp.exe : fatal error LNK1120: 4 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
Is there anyone who can kindly tell me how should I deal with it?
Thank you very much for your attention, and I’m looking forward to your kind aid.
Finally, I've solved this problem which is due to the undefined functions. I think my case is about a released software package rather than some specific procedure code, hence, it's a little different and relative simple.
Without knowing the specifics of the libraries you are using, I recommend that you try the following to deal with this error:
The error tells you that the linker is missing code for some function calls. This probably means that a library file is not found. Make sure that the linker can find all needed lib files. Check the property pages. Under the Linker->General->Additional library directories, make sure that the directories where your lib-files are located are present and under Linker->Input->Additional dependencies, make sure that the the lib-files are listed. Also make sure that the parameters are present for the different Configurations.
If this still does not help, check if your libraries depend on other libraries. These should be mentioned in the documentation of the libraries you are using.
I've not built this, but here's what I would try from the start. From what you've said, you've compiled the .lib files that it links against and it's failing during linking.
So here are your options...
1) You've either missed a .lib file in the input list for the linker.
2) The actual .lib file doesn't contain the symbol that the linker needs (you can check this by dumping the symbols of the .lib file)
3) Your .lib file is compiled with either the wrong platform than what you're linking with or with the wrong type ie. release/debug.
4) The symbols in your lib are decorated because you're compiling as C++ instead of C, or visa-versa.
If you go through the above steps above, I'm pretty sure you'll find your problem, but you've not really given enough information to properly answer your question. Personally, I'd have a guess that you're compiling C as C++ or you've got the wrong platform type set for one of your lib files.
Thank you all very much for your patient and detailed advices that inspired me, and I finally find out that I should add some C files which define the necessary functions into my project. The detailed solution is as follows.
For example, I want to eliminate
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
Step 1: Run
f2c iladlr.f
In the Visual Stuido Command Prompt and generate iladlr.c.
Step 2: Add iladlr.c to my project.
Step 3: Rebuild.
Finally, everything goes well.

Chromium Embedded Framework VS2013 strings error

I am converting a project which uses CEF, from VS2010 Express to VS2013 Express. I recompiled libcef_d.lib and libcef_dll_wrapper_d.lib with VS2013 just fine. But now I have problems when I try to link the libs in my main project. How can I resolve this?
WebBrowser_Handler.obj : error LNK2001: unresolved external symbol _cef_string_utf16_clear
WebBrowserManager.obj : error LNK2001: unresolved external symbol _cef_string_utf16_clear
libcef_dll_wrapper_d.lib(browser_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
libcef_dll_wrapper_d.lib(cookie_manager_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
libcef_dll_wrapper_d.lib(drag_data_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
First, make sure that libcef_dll_wrapper uses the same runtime library as your project: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx.
Second, if you build CEF from source code and you'd changed something in CEF include folder, you need to run the translator tool:
cd x:\path\to\cef\tool
translator.bat

'LIBCMT' conflicts with use of other libs + unresolved external symbols

I have a program using OpenGL 3.2(+libs) and FreeType2. Then an other program with Boost and OpenSSL. The OpenGL side was to make sure text could be rendered and the boost/openssl program is to do a secure login/game server.
Both programs work fine by them selfs.
However adding Boost and OpenSSL to the game(GL + freetype) project caused it to fail to link.
I have linked the following libs as well as including there includes folder.
glimg.lib
glutil.lib
glfw.lib
opengl32.lib
freetype.lib
glew32.lib
user32.lib
libeay32.lib
ssleay32.lib
The linker error is.
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__DeregisterEventSource#4
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA#36
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__RegisterEventSourceA#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteDC#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetBitmapBits#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__BitBlt#36
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetObjectA#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__SelectObject#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleBitmap#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetDeviceCaps#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleDC#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateDCA#16
1>.\BasicTexture.exe : fatal error LNK1120: 13 unresolved externals
Runtime Library is set to Multi-threaded DLL (/MD)
I have no idea what to do I would really appreciate any help.
You are trying to compile with /MD, which is probably the right choice, but some code (probably one of the libraries) was built with /MT, and you can't have it both ways in the same program. You need to figure out which library was built with /MT and rebuild it with /MD.
Unresolved external error messages are produced when the compiler generates code referencing externally defined objects or functions and the linker fails to find those. To generate code invoking a function call the compiler only needs a declaration:
extern "C" BOOL DeregisterEventSource ( HANDLE hEventLog );
This is enough information to produce a call instruction (except for the target address). The extern keyword informs the compiler that the implementation is defined elsewhere. Consequently it cannot know the target address which has to be filled in later. When the compiler is done it is the linker's job to connect the pieces together. It uses the information gathered from the import libraries to look up the required offsets.
Windows API calls are easily spotted in the error log. They have an __imp__ prefix and sometimes an A or W postfix followed by #<n> where <n> indicates the number of bytes required for the arguments. In the case of a Windows API call you can then look up the function in the MSDN (like DeregisterEventSource). Towards the bottom are the Requirements where you can find the import library name.
The conflict warning indicates that not all of the modules use the same runtime library. Even though this is just a warning it is a serious issue and should be resolved. You get this warning if you mix /MD and /MT compiler switches, but also, if you mix release and debug runtime libraries (like /MD and /MDd). To diagnose this message you can use the /VERBOSE:LIB linker switch to determine which libraries the linker is searching. Additional information on this warning can be found at this MSDN link.

Protobuffers in c++ and error LNK2019: unresolved external symbol

I am new to c++ and visual studio 2012 so probably the problem is between the screen and the chair. I performed the following steps;
I made a simple proto file with the option optimize_for = LITE_RUNTIME
Create the matching h and c files with protoc
Compiled the library libprotobuf-lite.lib
Created a new console Visual Studio 2012 project.
Copied the libprotobuf-lite.lib where my single source file is.
Created a new folder named protobuffers
Copied the c, h and the google directory from the protobuffers src directory to the protobuffers folder
Added the protobuffers folder as an Additional Include Directory
Added the library file to the linker through Additional Dependencies
Compiled the following source file;
#include <iostream>
#include "protobuffers\genome.pb.h"
int main()
{
genomeMessage::Genome genome;
return 0;
}
Stuck... I get the following error;
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
1>C:\Projects\testproto\x64\Debug\testproto.exe : fatal error LNK1120: 2 unresolved externals
So I know it is not a missing lib file because if I move the lib file the linker complains that it can't find it. The problem is that I have no clue how to fix this ... anyone?
According to this message:
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
the source file that declares genomeMessage::Genome::Genome(void) and genomeMessage::Genome::~Genome(void) is not part of your project.
In particular, it sounds like you haven't added the genome.pb.cc file (which is created by the Protocol Buffers compiler) to your project.

Issue moving project to Visual Studio 2012

I've just moved over to Visual Studio 2012 RC to give it a test run. But I'm having problems with getting my DirectX 11 game project to work with it. When I build I get 1152 warnings that all look like this:
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\dwrite.h(4972): warning C4005: 'DWRITE_E_NOFONT' : macro redefinition
1> c:\program files (x86)\windows kits\8.0\include\shared\winerror.h(50217) : see previous definition of 'DWRITE_E_NOFONT'
They come from all the DirectX headers and each one is for a different macro. I also get some unresolved external symbols I didn't get before:
1>base.obj : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z) referenced in function __unwindfunclet$??__EgGame##YAXXZ$0
1>game.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z)
1>world.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,int,char const *,int)" (??3#YAXPAXHPBDH#Z)
The only place I would think delete would be overloaded is in #include <crtdbg.h>, which I am using in my project. But the thing is, all this working in Visual Studio 2010.
Not to sure what the problem is. Am I missing any steps when converting the projects?
I should also mention that my computer previously crashed (I only lost Windows, and the registry) so I've had to reinstall most of my programs. I don't know if this will come into play, but I haven't compiled the project on VS2010 since the crash.
You need to recompile all your libraries with VS2012 in order to fix this issue. It is a problem with the new C run-time library included with the VS2012.