-5

i try to create my own Library to use it in other projects in C/C++. my static library use the library xercesc. Eclipse try to compile the xercesc included lib with gcc and not g++. If i try to compile my code i got the following error:

    Info: Internal Builder is used for build
g++ "-IC:\\00_Projects\\Ladeplanberechnung\\LadeplanLib\\lib\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\viterbi\\ViterbiAlgorithm.o" "..\\src\\viterbi\\ViterbiAlgorithm.cpp" 
In file included from ..\src\viterbi\LocalSuitability.h:11:0,
                 from ..\src\viterbi\ViterbiAlgorithm.h:8,
                 from ..\src\viterbi\ViterbiAlgorithm.cpp:8:
gcc "-IC:\\00_Projects\\Ladeplanberechnung\\LadeplanLib\\lib\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "lib\\include\\xercesc\\util\\RefArrayVectorOf.o" "..\\lib\\include\\xercesc\\util\\RefArrayVectorOf.c" 
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:25:1: error: unknown type name 'XERCES_CPP_NAMESPACE_BEGIN'
     XERCES_CPP_NAMESPACE_BEGIN
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:30:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem>
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:39:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> RefArrayVectorOf<TElem>::~RefArrayVectorOf()
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:49:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> void
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:61:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> void RefArrayVectorOf<TElem>::removeAllElements()
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:74:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> void RefArrayVectorOf<TElem>::
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:102:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> void RefArrayVectorOf<TElem>::removeLastElement()
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:112:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
     template <class TElem> void RefArrayVectorOf<TElem>::cleanup()
              ^
    ..\lib\include\xercesc\util\RefArrayVectorOf.c:122:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
     XERCES_CPP_NAMESPACE_END
     ^~~~~~~~~~~~~~~~~~~~~~~~

Why eclipse try to compile the xercesc? Can i force eclipse to compile the project with g++.

MoSad
  • 31
  • 2
  • Downvoters: Maybe tell MoSad why you're downvoting, so they have a chance to learn and improve the question. – Max Vollmer Aug 06 '18 at 14:44
  • 1
    There's no such thing as C/C++ - it looks like you have C++ code, but trying to compile it with a C compiler. – Toby Speight Aug 06 '18 at 17:20
  • i try to use the c library for xml parsing "xerces-c". linked all the paths for include und library in eclipse project settings but its also trying to compile the include folder from the xerces-c library – MoSad Aug 07 '18 at 11:25
  • What's "xerces-c"? Apache Xerces is available in C++, Java and Perl. What you are compiling there is C++, not C. – Max Vollmer Aug 07 '18 at 13:01
  • I have edited my question and i hope it is clear what i try to do with. – MoSad Aug 09 '18 at 08:42

1 Answers1

0

You need to explicitly tell gcc that your source code is C++, as it will assume a file ending in .c is written in C. Add -x c++ to the command and it should work:

gcc "-IC:\\00_Projects\\Ladeplanberechnung\\LadeplanLib\\lib\\include" -O0 -g3 -Wall -c -fmessage-length=0 -x c++ -o "lib\\include\\xercesc\\util\\RefArrayVectorOf.o" "..\\lib\\include\\xercesc\\util\\RefArrayVectorOf.c"
Max Vollmer
  • 8,412
  • 9
  • 28
  • 43