xerces class를 사용하는데요..static method사용 부분에서 에러

junteken의 이미지

일단 코드를 보자면 다음과 같습니다.
다음 15번 line에서 컴파일시 error가 납니다.

#include "/xerces/xerces-c-src_2_5_0/src/xercesc/parsers/XercesDOMParser.hpp"
     2  #include "/xerces/xerces-c-src_2_5_0/src/xercesc/dom/DOM.hpp"
     3  #include "/xerces/xerces-c-src_2_5_0/include/xercesc/sax/HandlerBase.hpp"
     4  #include "/xerces/xerces-c-src_2_5_0/include/xercesc/util/XMLString.hpp"
     5  #include "/xerces/xerces-c-src_2_5_0/include/xercesc/util/PlatformUtils.hpp"
     6  #include <iostream>
     7
     8
     9
    10  using namespace std;
    11
    12  int main(void)
    13  {
    14          try{
    15                  XMLPlatformUtils::Initialize();
    16          }
    17          catch(const XMLException &toCatch){
    18                  char *message= XMLString::transcode(toCatch.getMessage());
    19                  cout<<"Error during initialization!:\n"<<message<<"\n";
    20                  XMLString::release(&message);
    21                  return 1;
    22          }
    23
    24          char *xmlFile= "GetPortsOfNode.xml";
    25          XercesDOMParser *parser= new XercesDOMParser();
    26
    27          parser->setValidationScheme(XercesDOMParser::Val_Always);
    28          parser->setDoNamespaces(true);
    29
    30          ErrorHandler *errHandler=(ErrorHandler*)new HandlerBase();
    31          parser->setErrorHandler(errHandler);
    32
    33
    34          try{
    35                  parser->parse(xmlFile);
    36          }
    37          catch(const XMLException &toCatch){
    38                  char *message= XMLString::transcode(toCatch.getMessage());
    39                  cout<<"EXception message is :\n"<<message<<"\n";
    40                  XMLString::release(&message);
    41                  return -1;
    42          }
    43          catch(const SAXParserException &toCatch){
    44                  char *message = XMLString::transcode(toCatch.getMessage());
    45                  cout<<"Exception message is :\n"<<message<<"\n";
    46                  XMLString::release(&message);
    47                  return -1;
    48          }
    49          catch(...){
    50                  cout<<"Unexpected Exception \n";
    51                  return -1;
    52          }
    53
    54          delete parser;
    55          delete errHandler;
    56          return 0;
    57  }

******에러메시지*************
test.cpp:15: error: `XMLPlatformUtils' undeclared (first use this function)
test.cpp:15: error: (Each undeclared identifier is reported only once for each
function it appears in.)
test.cpp:15: error: parse error before `::' token

*************************
헤더파일을 보면 분명 저 Initialize()가 static method로 선언이 되어있는데요...컴파일이 안되네요...ㅠ.ㅠ
누가 좀 도와주세욤...

pynoos의 이미지

필요한 파일이 include되지 않아서 그렇습니다.

사족이지만,

테스트 하는게 아니시라면,

include를 절대 경로로 하지마시고 file name만 준다음

-I option으로 directory를 넘기시는 것이 좋습니다.

junteken의 이미지

관리자님 말씀대로 -I옵션을 주어서 다음과 같은 소스로 테스트를 해보았습니다.

#include "xercesc/util/PlatformUtils.hpp"

int main(void):
{
        try{
                XMLPlatformUtils::Initialize();
        }
        catch(const XMLException &toCatch){
        }
        return 0;
}

이것을 컴파일 하니깐 다음과 같은 컴파일 에러가 뜨네요...
**********에러 메시지***************
bash-2.05$ make in.o
g++ -c in.cpp -I/xerces/xerces-c-src_2_5_0/include
in.cpp: In function `int main()':
in.cpp:6: error: `XMLPlatformUtils' undeclared (first use this function)
in.cpp:6: error: (Each undeclared identifier is reported only once for each
function it appears in.)
in.cpp:6: error: parse error before `::' token
in.cpp:8: error: parse error before `&' token
make: *** [in.o] Error 1

************************************

크윽...어제 밤부터 계속 삽질입니다...ㅠ.ㅠ

pynoos의 이미지

XMLPlatformUtils 함수가 선언된 hpp를 include 하셔야하지요..
cd /xerces/xerces-c-src_2_5_0/include
grep -wr XMLPlatformUtils .

junteken의 이미지

다시 물어서 죄송합니다만....PlatformUtils.hpp파일안에 보면 XMLPlatformUtils 라는 class가 선언이 되어있습니다. 그리고 Initialize method도 static으로 선언이 되어있습니다...
어찌된 일일까용....ㅠ.ㅠ

pynoos의 이미지

-E 나 -save-temps option을 넣어 전처리한 결과를 한 번 분석해보세요.

-save-temps 는 .ii 파일이 만들어 집니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.