I am running out of ideas; I can suggest you to do:
a) remove all the "using namespace" directive and fully qualify everything
b) add __cdecl to the classes the linker complains about
and in any case I would add copy constructors like content(const
content& other) to avoid relying on the default behaviour of the compiler.
Alberto
Javier Gálvez Guerrero wrote:
There are no dlls for my classes, I mean, the only files I have are .h for
the header, .cpp for the definition of the interface and constructors and
another cpp for the test of the corresponding class.
So what I have is one folder for "content", where I have content.h and
content.cpp, and another named contents_manager with has a vector of
contents and a method for parsing the XML file and fill the vector.
I have another class named user and users_manager and is the same but
without XML parsing and it works perfectly. I have no copy constructor in
neither of them...
Sorry if my questions go beyond Xerces. Your help is much appreciated, but
if you think that's enough you can stop as soon as you want, of course.
Thank you a lot,
Javi
2007/11/29, Alberto Massari <[EMAIL PROTECTED]>:
Javier,
these errors are strictly MSVC, Xerces is not involved.
Is your "content" class declared in a separate DLL? In this case this
page could be right:
http://msdn2.microsoft.com/en-us/library/ms235590(vs.80).aspx
You should specify __cdecl in the class declaration, as the /clr switch
automatically assumes __clrcall.
Alberto
PS: BTW, does you "contents" class have a copy constructor?
Javier Gálvez Guerrero wrote:
The two constructors are declared in content.h:
content(void);
content(string ident);
and defined in content.cpp:
content::content(void){
}
content::content(string ident){
id = ident;
}
Then, in contents_manager.cpp:
content contents_manager::get_content(string id){
content c;
for(int i=0; i<size; i++){
c = contents_list.at(i); // contents_list is a vector<content>
if(c.id == id)
return c;
}
return NULL;
}
The only thing I think can cause this is the line in red, according to
what
is said here
<http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>
vector.at(i)
returns a reference so, why can't I do this? Compiling there is no
error...
I don't know if what is happening has anything to do with Xerces or is
only
because my C++ programing "knowledge"...sorry.
2007/11/29, Alberto Massari <[EMAIL PROTECTED]>:
Javier Gálvez Guerrero wrote:
I have just created my main method. I am creating the "parser" class
in
my
project, so this is not the final project yet. I create a class and
test
it
with a corresponding main when I have compiled without errors (well,
with
the only one that there is no main). Now there are 8 errors (with the
main
defined).
See the quoted text, please.
2007/11/29, Alberto Massari <[EMAIL PROTECTED]>:
[...]
Ventana Resultados
Vinculando...
contents_manager.obj : warning LNK4248: símbolo (token) de typeref
sin
resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
ejecutar la imagen
contents_manager.obj : warning LNK4248: símbolo (token) de typeref
sin
resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
ejecutar la imagen
I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
instead
of ".")
I have only copied what the Visual C++ 2005 has given as an output
when
compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
not a
colon. Actually, I have not used this on my project. I've only created
a
parser and worked with the DOMNode API:
In this case it could be caused by the various "using namespace"
directives, that under /clr have a different separator. I think the
only
way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE
and
add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
// contents_manager.cpp
#include "../include/gincludes.h"
#include "contents_manager.h"
//...
void contents_manager::load_guide(string xml_path){
XMLPlatformUtils::Initialize();
XercesDOMParser* parser = new XercesDOMParser();
parser->parse(xml_path.c_str());
DOMNode* root = parser->getDocument();
DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
*child_aux5,
*child_aux6, *child_aux7;
// Check that the XML file defines the content guide
if(XMLString::transcode(root->getNodeName()) == "contents"){
Beware, this test is wrong; transcode returns a pointer, so you are
comparing two pointers, and not two strings. Either use strcmp, or
XMLString::equals, or build two std::string objects. And don't forget
to
call XMLString::release on the pointer returned by transcode, or you'll
leak memory.
for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
child_aux1 = child_aux1->getNextSibling()){
char* child1_name =
XMLString::transcode(child_aux1->getNodeName());
//...
delete parser;
XMLPlatformUtils::Terminate();
}
That is the only I have done in my class regarding Xerces. In the
header
file I have included these:
//contents_manager.h
#include "../include/gincludes.h"
#include "../content/content.h"
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace std;
XERCES_CPP_NAMESPACE_USE
class contents_manager {
//...
So that's all.
Sorry, I extracted the wrong symbol from the spanish description: it
complains that contents_manager::get_content is using two constructors
for the "content" class that cannot be
found,content::content(std::string) and content::content(void). Double
check if you have implemented them, or just declared in the header
file.
Alberto