error LNK2001: unresolved external symbol, due to ifstream object - c++

error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class std::locale::id std::codecvt::id" (__imp_?id#?$codecvt#DDH#std##2V0locale#2#A)
1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::codecvt::_Getcat(class std::locale::facet const * *,class std::locale const *)" (__imp_?_Getcat#?$codecvt#DDH#std##SAIPAPBVfacet#locale#2#PBV42##Z)
1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int
__thiscall std::codecvt::unshift(int &,char *,char *,char * &)const " (__imp_?unshift#?$codecvt#DDH#std##QBEHAAHPAD1AAPAD#Z)
1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt::out(int &,char const *,char const *,char const * &,char *,char *,char * &)const " (__imp_?out#?$codecvt#DDH#std##QBEHAAHPBD1AAPBDPAD3AAPAD#Z)
1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt::in(int &,char const *,char const *,char const * &,char *,char *,char * &)const " (__imp_?in#?$codecvt#DDH#std##QBEHAAHPBD1AAPBDPAD3AAPAD#Z)
1>C:\perforce\sw\apps\gpu\drivers\common\logassert\Release\logassert.dll : fatal error LNK1120: 5 unresolved externals
Issue Explanation:
Now I'm seeing above linking error when I add this source line "ifstream fin;" to source file. If I remove this source line then code successfully compiles. I already added supported header files and and namespace for ifstream object. Not sure, why I'm seeing this linking error. Searched similar error on SO and tried their suggested solutions but those solution didn't work for me. Any idea?
SAMPLE CODE
//In stdafx.h file below code is there
#pragma once
#include<iostream>
#include<fstream>
using namespace std;
//In program.cpp
#include "stdafx.h"
class A
{
void B();
ifstream fin; //now if I make this member static then issue goes away. Can anybody explain?
}

It looks like you're not linking against the standard library.
Since the error messages show __declspec, I'll suppose
a Windows environment, with Visual Studios. By default, this
should work: go into the properties of the project, then into
Linker: in General, Ignore Import Library should be No, and in
Input, Ignore All Default Libraries should be No, and Ignore
Specific Default Libraries should be empty. (These are the
defaults.)
Otherwise: this could be due to problems with your installation, e.g. if not all of the files are present.

Related

Reading from HDF5 file linker issue

I am trying to read HDF5 file, this's the first time I come across this file format so please bare with me. The issue that I am having right now is linking the hdf5 lib to my project on Visual Studio 2017.
This's what I've done so far:
Linker > Input > Additional Dependencies contains hdf5.lib
Linker > General > Additional Libraries Directories contains path to lib directory of my HDF5 installation
C/C++ > General > Additional Include Directories contains path to include directory of my HDF5 installation
I've add to PATH variable bin directory of my HDF5 installation
Following the steps of the solution proposed here.
However, I still have the following linker errors when I try to build my project.
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: __cdecl H5::DataSpace::DataSpace(int,unsigned __int64 const *,unsigned __int64 const *)" (??0DataSpace#H5##QEAA#HPEB_K0#Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: int __cdecl H5::DataSpace::getSimpleExtentDims(unsigned __int64 *,unsigned __int64 *)const " (?getSimpleExtentDims#DataSpace#H5##QEBAHPEA_K0#Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::DataSpace::~DataSpace(void)" (??1DataSpace#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: class H5::DataSet __cdecl H5::H5Location::openDataSet(char const *,class H5::DSetAccPropList const &)const " (?openDataSet#H5Location#H5##QEBA?AVDataSet#2#PEBDAEBVDSetAccPropList#2##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: enum H5T_class_t __cdecl H5::AbstractDs::getTypeClass(void)const " (?getTypeClass#AbstractDs#H5##QEBA?AW4H5T_class_t##XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual class H5::DataSpace __cdecl H5::DataSet::getSpace(void)const " (?getSpace#DataSet#H5##UEBA?AVDataSpace#2#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: void __cdecl H5::DataSet::read(void *,class H5::DataType const &,class H5::DataSpace const &,class H5::DataSpace const &,class H5::DSetMemXferPropList const &)const " (?read#DataSet#H5##QEBAXPEAXAEBVDataType#2#AEBVDataSpace#2#2AEBVDSetMemXferPropList#2##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::DataSet::~DataSet(void)" (??1DataSet#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: __cdecl H5::H5File::H5File(char const *,unsigned int,class H5::FileCreatPropList const &,class H5::FileAccPropList const &)" (??0H5File#H5##QEAA#PEBDIAEBVFileCreatPropList#1#AEBVFileAccPropList#1##Z) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl H5::H5File::close(void)" (?close#H5File#H5##UEAAXXZ) referenced in function main
1>EigenExperiment.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl H5::H5File::~H5File(void)" (??1H5File#H5##UEAA#XZ) referenced in function main
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DataSpace const & const H5::DataSpace::ALL" (?ALL#DataSpace#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::FileAccPropList const & const H5::FileAccPropList::DEFAULT" (?DEFAULT#FileAccPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::FileCreatPropList const & const H5::FileCreatPropList::DEFAULT" (?DEFAULT#FileCreatPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DSetMemXferPropList const & const H5::DSetMemXferPropList::DEFAULT" (?DEFAULT#DSetMemXferPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::DSetAccPropList const & const H5::DSetAccPropList::DEFAULT" (?DEFAULT#DSetAccPropList#H5##2AEBV12#EB)
1>EigenExperiment.obj : error LNK2001: unresolved external symbol "public: static class H5::PredType const & const H5::PredType::NATIVE_FLOAT" (?NATIVE_FLOAT#PredType#H5##2AEBV12#EB)
1>C:\Users\maxim\source\repos\EigenExperiment\x64\Debug\EigenExperiment.exe : fatal error LNK1120: 17 unresolved externals
1>Done building project "EigenExperiment.vcxproj" -- FAILED.
Also, I've attached the code I'm using, just in case I missed something.
Any hep is highly appreciated :)
#include <iostream>
#include <Eigen/Dense>
#include <filesystem>
#include <math.h>
#include "H5Cpp.h"
#include <vector>
#include <string>
using namespace std;
using namespace H5;
int main()
{
string ifn = "basler.h5";
string datasetPath = "/face_g_tobii/data";
// Open HDF5 file handle, read only
H5File fp(ifn.c_str(), H5F_ACC_RDONLY);
// access the required dataset by path name
DataSet dset = fp.openDataSet(datasetPath.c_str());
// get the dataspace
DataSpace dspace = dset.getSpace();
// get the dataset type class
H5T_class_t type_class = dset.getTypeClass();
// According to HDFView, this is a 32-bit floating-point
// get the size of the dataset
hsize_t rank;
hsize_t dims[2];
rank = dspace.getSimpleExtentDims(dims, NULL); // rank = 1
cout << "Datasize: " << dims[0] << endl; // this is the correct number of values
// Define the memory dataspace
hsize_t dimsm[1];
dimsm[0] = dims[0];
DataSpace memspace(1, dimsm);
// create a vector the same size as the dataset
vector<float> data;
data.resize(dims[0]);
cout << "Vectsize: " << data.size() << endl;
float data_out[65341];
for (int i = 0; i < 65341; i++)
{
data_out[i] = 0;
}
// pass pointer to the array (or vector) to read function, along with the data type and space.
dset.read(data_out, PredType::NATIVE_FLOAT, memspace, dspace); // FAILS
dset.read(data_out, PredType::NATIVE_FLOAT, dspace); // FAILS
dset.read(data.data(), PredType::NATIVE_FLOAT, memspace, dspace); // FAILS
// close the HDF5 file
fp.close();
}
It turned out the external libraries should be named first, what worked for me was:
1.4 Select Linker->Input and beginning with the
"Additional Dependencies" line, enter the library names. The
external libraries should be listed first, followed by the HDF5
library, and then optionally the HDF5 High Level, Fortran or C++
libraries. For example, to compile a C++ application, enter:
szip.lib zlib.lib hdf5.lib hdf5_cpp.lib
This's from the documentation of HDF5, which I completely overlooked :/
i am trying with hdf5 for c++ on vs2019 and i did the stuff of adding
szip.lib zlib.lib hdf5.lib hdf5_cpp.lib but then i canĀ“t find both libs szip and zlib. Of course i did "H5_BUILT_AS_DYNAMIC_LIB" at preprocessor, but nothing.
According to the error, the project you built is the x64 version, I suggest you check whether the linked hdf5.lib is 32-bit or 64-bit? You should use the 64-bit hdf5.
And I suggest you could try to check whether the platform and the Configuration selection in the property page is x64 and debug.
I suggest you could select "All Platforms" for the platform and select "All Configurations" for the Configuration when changing the properties.

Unresolved External Symbol errors while using Catch2

I am trying to do Catch2 Unit Testing in Visual Studio. I have created a small test project to practice. When I try to compile this test project, I get a linker error. I am now trying to diagnose this linker error, but the Catch2.hpp header file contains thousands of lines of code. My hope is that someone who is more familiar with Catch2 or unit testing in general can diagnose what the issue is.
I will describe the process by which I created this project. I created a new project in a new solution. I have 4 files, all in the same directory, listed below.
The class I want to test:
//a.h
#pragma once
class A {
friend int A_Tester_Func1(A a);
public:
A(int num) : my_num_(num) {
}
private:
int my_num_;
};
The test:
//atester.cpp
#pragma once
#include "catch.hpp"
#include "a.h"
int A_Tester_Func1(A a) {
return a.my_num_;
}
TEST_CASE("a contains a positive integer", "[a]") {
//...
A a(3);
REQUIRE(A_Tester_Func1(a) == 3);
}
The main function that runs the tests:
//tester.cpp
#define CATCH_CONFIG_MAIN
#include "catch.hpp" // this should create the main function
The Catch2 Testing Framework:
// catch.hpp
/*
* Catch v2.13.2
* Generated: 2020-10-07 11:32:53.302017
*/
//~17-18k lines of code that from Catch2
#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
When I try to compile this code in Visual Studio using the Local Windows Debugger button, I get a bunch of Unresolved External Symbol linker errors. I believe I read somewhere that Catch2 is "partially compiled." That may have something to do with it, but I don't know. Following this guide (StackOverflow: Best practices for Unit testing with Catch2 in Visual Studio) has worked for me, but I'm trying to understand why the small example above is not successfully linking.
I have included the linker errors below for completeness, although I feel that they will probably not be necessary for the question.
1>atester.obj : error LNK2019: unresolved external symbol "public: __thiscall Catch::StringRef::StringRef(char const *)" (??0StringRef#Catch##QAE#PBD#Z) referenced in function "public: class Catch::BinaryExpr<int const &,int const &> const __thiscall Catch::ExprLhs<int const &>::operator==<int>(int const &)" (??$?8H#?$ExprLhs#ABH#Catch##QAE?BV?$BinaryExpr#ABHABH#1#ABH#Z)
1>atester.obj : error LNK2019: unresolved external symbol "struct Catch::ITestInvoker * __cdecl Catch::makeTestInvoker(void (__cdecl*)(void))" (?makeTestInvoker#Catch##YAPAUITestInvoker#1#P6AXXZ#Z) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'autoRegistrar1''(void)" (??__EautoRegistrar1#?A0xf9ca9c7d##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: __thiscall Catch::NameAndTags::NameAndTags(class Catch::StringRef const &,class Catch::StringRef const &)" (??0NameAndTags#Catch##QAE#ABVStringRef#1#0#Z) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'autoRegistrar1''(void)" (??__EautoRegistrar1#?A0xf9ca9c7d##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: __thiscall Catch::AutoReg::AutoReg(struct Catch::ITestInvoker *,struct Catch::SourceLineInfo const &,class Catch::StringRef const &,struct Catch::NameAndTags const &)" (??0AutoReg#Catch##QAE#PAUITestInvoker#1#ABUSourceLineInfo#1#ABVStringRef#1#ABUNameAndTags#1##Z) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'autoRegistrar1''(void)" (??__EautoRegistrar1#?A0xf9ca9c7d##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Catch::AutoReg::~AutoReg(void)" (??1AutoReg#Catch##UAE#XZ) referenced in function "void __cdecl `anonymous namespace'::`dynamic atexit destructor for 'autoRegistrar1''(void)" (??__FautoRegistrar1#?A0xf9ca9c7d##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Catch::StringMaker<int,void>::convert(int)" (?convert#?$StringMaker#HX#Catch##SA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Catch::Detail::stringify<int>(int const &)" (??$stringify#H#Detail#Catch##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABH#Z)
1>atester.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Catch::ITransientExpression::~ITransientExpression(void)" (??1ITransientExpression#Catch##UAE#XZ) referenced in function "public: virtual __thiscall Catch::BinaryExpr<int const &,int const &>::~BinaryExpr<int const &,int const &>(void)" (??1?$BinaryExpr#ABHABH#Catch##UAE#XZ)
1>atester.obj : error LNK2019: unresolved external symbol "void __cdecl Catch::formatReconstructedExpression(class std::basic_ostream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class Catch::StringRef,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?formatReconstructedExpression#Catch##YAXAAV?$basic_ostream#DU?$char_traits#D#std###std##ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##3#VStringRef#1#1#Z) referenced in function "private: virtual void __thiscall Catch::BinaryExpr<int const &,int const &>::streamReconstructedExpression(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (?streamReconstructedExpression#?$BinaryExpr#ABHABH#Catch##EBEXAAV?$basic_ostream#DU?$char_traits#D#std###std###Z)
1>atester.obj : error LNK2019: unresolved external symbol "public: __thiscall Catch::AssertionHandler::AssertionHandler(class Catch::StringRef const &,struct Catch::SourceLineInfo const &,class Catch::StringRef,enum Catch::ResultDisposition::Flags)" (??0AssertionHandler#Catch##QAE#ABVStringRef#1#ABUSourceLineInfo#1#V21#W4Flags#ResultDisposition#1##Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____0(void)" (?____C_A_T_C_H____T_E_S_T____0##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: void __thiscall Catch::AssertionHandler::handleExpr(struct Catch::ITransientExpression const &)" (?handleExpr#AssertionHandler#Catch##QAEXABUITransientExpression#2##Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____0(void)" (?____C_A_T_C_H____T_E_S_T____0##YAXXZ)
1>atester.obj : error LNK2019: unresolved external symbol "public: void __thiscall Catch::AssertionHandler::handleUnexpectedInflightException(void)" (?handleUnexpectedInflightException#AssertionHandler#Catch##QAEXXZ) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____0##YAXXZ$0
1>atester.obj : error LNK2019: unresolved external symbol "public: void __thiscall Catch::AssertionHandler::complete(void)" (?complete#AssertionHandler#Catch##QAEXXZ) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____0##YAXXZ$0
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
What is causing these errors? How do I fix these errors while keeping catch.hpp in the same project as my source files?
In a .cpp file, add this to make the project a Catch2 test runner:
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
Read more at Supplying main() yourself
I ran into the same problem.
You need to keep #define CATCH_CONFIG_MAIN in the first line of the file, especially before other #include.
atester.cpp must not have the #pragma once directive. It's for header files, and while it may not be your source of trouble, it simply doesn't belong. Since you're not providing enough detail (namely: where's the minimized project file?), I have to be conservative here.
It seems that tester.cpp is not part of the project that you're building. Just because it's a file that exists on disk doesn't mean it's automatically picked up. You have to manually add it to the MSVC project. That's all there's to it. I use Catch2 with MSVS all the time and that's all it takes to make it work.

what is the meaning of these linker errors?

I wish I could ask "What libraries do i need to link" but it's quite specific (wwise engine integration), so I need help in working it out myself. The problem occurs when I attempt to create a variable of a type defined in a header file (compiler finds the header no problem). I get 22 linker errors but I don't understand the read out, could someone walk me through it and tell me precisely which symbol is missing so I can figure out what libraries I'm missing? and could it be anything other than a library not linking? Wwise comes with a demo project that compiles but doesnt link to any more libraries than I do.
Here are 5 of the errors. I'm using visual studio.
1>main.obj : error LNK2019: unresolved external symbol "public: enum AKRESULT __thiscall CAkDefaultIOHookBlocking::Init(struct AkDeviceSettings const &,bool)" (?Init#CAkDefaultIOHookBlocking##QAE?AW4AKRESULT##ABUAkDeviceSettings##_N#Z) referenced in function "bool __cdecl InitSoundEngine(void)" (?InitSoundEngine##YA_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CAkDefaultIOHookBlocking::GetDeviceDesc(struct AkDeviceDesc &)" (?GetDeviceDesc#CAkDefaultIOHookBlocking##UAEXAAUAkDeviceDesc###Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __thiscall CAkDefaultIOHookBlocking::GetDeviceData(void)" (?GetDeviceData#CAkDefaultIOHookBlocking##UAEKXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual enum AKRESULT __thiscall CAkDefaultIOHookBlocking::Read(struct AkFileDesc &,struct AkIoHeuristics const &,void *,struct AkIOTransferInfo &)" (?Read#CAkDefaultIOHookBlocking##UAE?AW4AKRESULT##AAUAkFileDesc##ABUAkIoHeuristics##PAXAAUAkIOTransferInfo###Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual enum AKRESULT __thiscall CAkDefaultIOHookBlocking::Write(struct AkFileDesc &,struct AkIoHeuristics const &,void *,struct AkIOTransferInfo &)" (?Write#CAkDefaultIOHookBlocking##UAE?AW4AKRESULT##AAUAkFileDesc##ABUAkIoHeuristics##PAXAAUAkIOTransferInfo###Z)
The symbols are:
enum AKRESULT CAkDefaultIOHookBlocking::Init(struct AkDeviceSettings const &,bool)
virtual void CAkDefaultIOHookBlocking::GetDeviceDesc(struct AkDeviceDesc &)
virtual unsigned long CAkDefaultIOHookBlocking::GetDeviceData(void)
virtual enum AKRESULT CAkDefaultIOHookBlocking::Read(struct AkFileDesc &,struct AkIoHeuristics const &,void *,struct AkIOTransferInfo &)
virtual enum AKRESULT CAkDefaultIOHookBlocking::Write(struct AkFileDesc &,struct AkIoHeuristics const &,void *,struct AkIOTransferInfo &)
As far as I can tell, you only have the header that declares the class CAkDefaultIOHookBlocking, which means that you attempt to use any of the above symbols you'll need to link against the library.
Wwise comes with a demo project that compiles but doesnt link to any more libraries than I do.
Either the symbols aren't used, or the source files that defines those symbols is compiled in that project - http://gmwwise.googlecode.com/svn-history/r2/trunk/GMWwise/wwise/AkDefaultIOHookBlocking.cpp
You have a file AkDefaultIOHookBlocking.cpp that hasn't been added to the project you're building.

Can I use __stdcall convention while using Xerces-C 3.0? I get linker errors

In my project it is crucial I use __stdcall. However, I get this:
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static void __cdecl xercesc_3_0::XMLString::release(unsigned short * *,class xercesc_3_0::MemoryManager * const)" (?release#XMLString#xercesc_3_0##SAXPEAPEAGQEAVMemoryManager#2##Z)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static char * __cdecl xercesc_3_0::XMLString::transcode(unsigned short const * const,class xercesc_3_0::MemoryManager * const)" (?transcode#XMLString#xercesc_3_0##SAPEADQEBGQEAVMemoryManager#2##Z)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static unsigned short * __cdecl xercesc_3_0::XMLString::transcode(char const * const,class xercesc_3_0::MemoryManager * const)" (?transcode#XMLString#xercesc_3_0##SAPEAGQEBDQEAVMemoryManager#2##Z)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static char const * const xercesc_3_0::XMLUni::fgXercescDefaultLocale" (?fgXercescDefaultLocale#XMLUni#xercesc_3_0##2QBDB)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static class xercesc_3_0::MemoryManager * xercesc_3_0::XMLPlatformUtils::fgMemoryManager" (?fgMemoryManager#XMLPlatformUtils#xercesc_3_0##2PEAVMemoryManager#2#EA)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static class xercesc_3_0::DOMImplementation * __cdecl xercesc_3_0::DOMImplementationRegistry::getDOMImplementation(unsigned short const *)" (?getDOMImplementation#DOMImplementationRegistry#xercesc_3_0##SAPEAVDOMImplementation#2#PEBG#Z)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static unsigned short const * const xercesc_3_0::XMLUni::fgDOMWRTFormatPrettyPrint" (?fgDOMWRTFormatPrettyPrint#XMLUni#xercesc_3_0##2QBGB)
1>ExchangeParser.obj : error LNK2001: unresolved external symbol "public: static unsigned short const * const xercesc_3_0::XMLUni::fgDOMXMLDeclaration" (?fgDOMXMLDeclaration#XMLUni#xercesc_3_0##2QBGB)
Any help?
Xerces is open source, so why not just compile your own variant that uses __stdcall as the default convention, then you won't have the linkage errors.
It even comes with projects for every Windows IDE (including MSVC, which it appears you are using), so its merely a matter of loading it up, change one global option and hitting compile (you may need to change some places where __cdecl must be explicitly used, but the compiler will error on these locations when you build it).

gSoap compilation with c++

I'm trying to get a simple example working using gSoap, for VS2008.
I've done the following:
wsdl2h -o Init.h http://myservices/InitalisationService.asmx?WSDL
And then this:
soapcpp2 -I "C:\3pSDK\gsoap-2.7\gsoap\import" -i -C -limport Init.h
which produces many files. My project folder looks like this:
// generated files
Init.h
InitalisationServiceSoap.initalizePlayer.req.xml
InitalisationServiceSoap.initalizePlayer.res.xml
InitalisationServiceSoap.nsmap
InitalisationServiceSoap12.initalizePlayer.req.xml
InitalisationServiceSoap12.initalizePlayer.res.xml
InitalisationServiceSoap12.nsmap
ortC.cpp
ortH.h
ortInitalisationServiceSoap12Proxy.cpp
ortInitalisationServiceSoap12Proxy.h
ortInitalisationServiceSoapProxy.cpp
ortInitalisationServiceSoapProxy.h
ortMatlab.c
ortMatlab.h
ortStub.h
// Project Files
ReadMe.txt
stdafx.cpp
stdafx.h
WebServicesClient.cpp
WebServicesClient.vcproj
targetver.h
// files added to the project from gSoap folder
stdsoap2.cpp
stdsoap2.h
typemap.dat
When I build, I get a lot of linker errors (unresolved externals). I can't find anything to link against (e.g. no binary libraries) - what am I missing?
I believe that this may have something to do with the following from the docs:
To complete the build, compile and
link the generated soapC.cpp,
soapcalcProxy.cpp, and the run-time
gSOAP engine -lgsoap++ (or use source
stdsoap2.cpp in case libgsoap++.a is
not installed) with your code.
is there a gsoap++ library for win32?
1>Compiling...
1>WebServicesClient.cpp
1>ortC.cpp
1>Generating Code...
1>Linking...
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultcode referenced in function _http_response
1>stdsoap2.obj : error LNK2001: unresolved external symbol _namespaces
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_getheader referenced in function _soap_recv_header
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultsubcode referenced in function _soap_set_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultstring referenced in function _soap_set_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_putfault referenced in function _soap_send_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_putheader referenced in function _soap_send_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_serializefault referenced in function _soap_send_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_serializeheader referenced in function _soap_send_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_getfault referenced in function _soap_recv_fault
1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultdetail referenced in function _soap_set_error
1>ortC.obj : error LNK2019: unresolved external symbol "void * __cdecl soap_class_id_enter(struct soap *,char const *,void *,int,unsigned int,char const *,char const *)" (?soap_class_id_enter##YAPAXPAUsoap##PBDPAXHI11#Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_in_std__string(struct soap *,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,char const *)" (?soap_in_std__string##YAPAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PAUsoap##PBDPAV12#1#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_putindependent(struct soap *)" (?soap_putindependent##YAHPAUsoap###Z) referenced in function "int __cdecl soap_put_std__string(struct soap *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,char const *,char const *)" (?soap_put_std__string##YAHPAUsoap##PBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PBD2#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_getindependent(struct soap *)" (?soap_getindependent##YAHPAUsoap###Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_get_std__string(struct soap *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,char const *,char const *)" (?soap_get_std__string##YAPAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PAUsoap##PAV12#PBD2#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_fdelete(struct soap_clist *)" (?soap_fdelete##YAHPAUsoap_clist###Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_instantiate_std__string(struct soap *,int,char const *,char const *,unsigned int *)" (?soap_instantiate_std__string##YAPAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PAUsoap##HPBD1PAI#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "void __cdecl soap_default_int(struct soap *,int *)" (?soap_default_int##YAXPAUsoap##PAH#Z) referenced in function "public: virtual void __thiscall _ns1__initalizePlayerResponse::soap_default(struct soap *)" (?soap_default#_ns1__initalizePlayerResponse##UAEXPAUsoap###Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_out_int(struct soap *,char const *,int,int const *,char const *)" (?soap_out_int##YAHPAUsoap##PBDHPBH1#Z) referenced in function "int __cdecl soap_out__ns1__initalizePlayerResponse(struct soap *,char const *,int,class _ns1__initalizePlayerResponse const *,char const *)" (?soap_out__ns1__initalizePlayerResponse##YAHPAUsoap##PBDHPBV_ns1__initalizePlayerResponse##1#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_ignore_element(struct soap *)" (?soap_ignore_element##YAHPAUsoap###Z) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" (?soap_in__ns1__initalizePlayerResponse##YAPAV_ns1__initalizePlayerResponse##PAUsoap##PBDPAV1#1#Z)
1>ortC.obj : error LNK2019: unresolved external symbol "int * __cdecl soap_in_int(struct soap *,char const *,int *,char const *)" (?soap_in_int##YAPAHPAUsoap##PBDPAH1#Z) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" (?soap_in__ns1__initalizePlayerResponse##YAPAV_ns1__initalizePlayerResponse##PAUsoap##PBDPAV1#1#Z)
1>G:\Prototypes\WebServicesClient\Debug\WebServicesClient.exe : fatal error LNK1120: 19 unresolved externals
1>Build log was saved at "file://g:\Prototypes\WebServicesClient\WebServicesClient\Debug\BuildLog.htm"
1>WebServicesClient - 20 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Okay, for those frustrated with the docs on the gSoap site, using VS2008 to compile a quick client only example, here's the steps (servers are different).
Generate the header file from the WSDL:
wsdl2h -o Init.h http://bleh.com/myservice.asmx?WSDL
Generate the soap client files:
soapcpp2 -C -IC:\3pSDK\gsoap-2.7\gsoap\import Init.h
Ensure you add the following files to your solution for build:
soapC.cpp, soapClient.cpp, and stdsoap2.cpp
Ensure that, for each of these files, you select the compiler option "Not using Pre-Compiled headers". (file Properties -> C++ -> Precompiled Headers -> Create/Use Precompiled header).
Finally, add the .nsmap file generated for your proxy to the stdafx.h (or in your main if your project isn't using pre-compiled headers).
Here's a sample that makes a simple query:
// WebServicesClient.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "init/soapInitServiceSoapProxy.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
std::string user = "AAAA";
std::string pass = "BBBB";
InitServiceSoap service;
_ns1__initPlayer query;
_ns1__initPlayerResponse ans;
query.psParam1 = &user;
query.psParam2 = &pass;
if( service.__ns2__initPlayer(&query, &ans) == SOAP_OK )
{
cout << "success!" << endl;
}
cin.get();
return 0;
}
hope this helps someone!