Author Topic: Application linker errors to Xercesc (XML Parser) with g++ compiler  (Read 4168 times)

Offline pradeep

  • Single posting newcomer
  • *
  • Posts: 5
There are linker errors in referencing Namspace::XMLString though the libxerces-c_static_2D.a is added in linker settings and I tried to do go to declaration on XMLString by selecting the option of RMB menu, it throws a prompt saying undefined but the build successful in visual studio. So in codeblocks I am seeing linker error as "undefined reference to `_imp___ZN11xercesc_2_89XMLString7releaseEPPc'|" though the header file XMLString.hpp is added.

Can you help me on how to resolve these linker errors.



Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pradeep

  • Single posting newcomer
  • *
  • Posts: 5
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #2 on: October 24, 2016, 07:37:45 pm »
Hi Tim,

I have followed instructions and added the required includes and .a/.obj files at Linker settings.

I am still seeing the same undefined errors at line:

XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();

Is it due to gcc incompatibility with xerces scope resolution? It works perfectly in visual studio.

Thanks,
Pradeep

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #3 on: October 25, 2016, 12:13:58 am »
Hi Tim,

I have followed instructions and added the required includes and .a/.obj files at Linker settings.

I am still seeing the same undefined errors at line:

XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();

Is it due to gcc incompatibility with xerces scope resolution? It works perfectly in visual studio.

Thanks,
Pradeep

Without more information I can NOT say what is the cause of the problem; but, user error is a good guess.

Do you know how to use Libraries?
Do you know you CAN NOT mix c++ libraries from different compilers and in some cases from different compiler versions?

Post a full build log as stated in the CB FAQs.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #4 on: October 25, 2016, 12:16:53 am »
Wild guess is you forgot to define a macro that says you are planning on linking to a static or DLL library.

Read the library documentation to see if this guess is true.

From http://svn.apache.org/viewvc/xerces/c/trunk/doc/build.xml?view=markup
Code: [Select]
<note>If you are linking your application to the static
316                   &XercesCName; library,
317                   then you will need to compile your application with the
318                   XERCES_STATIC_LIBRARY preprocessor macro defined in order
319                   to turn off the DLL import/export mechanism.</note>

Please read the fine manual next time!

Tim S.
« Last Edit: October 25, 2016, 01:54:27 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pradeep

  • Single posting newcomer
  • *
  • Posts: 5
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #5 on: October 25, 2016, 06:43:40 am »
Quote
<note>If you are linking your application to the static
316                      &XercesCName; library,
317                      then you will need to compile your application with the
318                      XERCES_STATIC_LIBRARY preprocessor macro defined in order
319                      to turn off the DLL import/export mechanism.</note>

Hi Tim,

Thanks for your response,

I have added the macro XERCES_STATIC_LIBRARY in Compiler settings -> #defines, but still I am seeing the undefined reference to errors.

Quote
Without more information I can NOT say what is the cause of the problem; but, user error is a good guess.

Do you know how to use Libraries?
Do you know you CAN NOT mix c++ libraries from different compilers and in some cases from different compiler versions?

Post a full build log as stated in the CB FAQs.


Hi Tim,

I have built the xerces library with g++ compiler and got static lib and dll libxerces-c_static_2D.a and xerces-c_static_2D.dll which I am using in my application.


here is the build log:

for the first project:
mingw32-g++.exe -g -W -O0 -DWIN32 -D_DEBUG -D_LIB  -c XXX.cpp -o ..\..\obj\w2k\dbg\src\w2k\XXX.o this continues for all the files

for the second project:
mingw32-g++.exe -W -O0 -DXERCES_STATIC_LIBRARY -D_DEBUG -DWIN32 -D_CONSOLE -DIL_STD -DOSLMSDLL -DINTEL -IC:\Libraries\xerces-c_2_8_0\include -I

Regards,
Pradeep

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #6 on: October 25, 2016, 02:22:12 pm »
Post the full build log or I will just ignore you!!!

You DID NOT even post the linking command!!!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pradeep

  • Single posting newcomer
  • *
  • Posts: 5
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #7 on: October 27, 2016, 01:08:59 pm »
Hi Tim,

Hope you are doing good,

I have removed all the warnings, undefined reference to errors from the build log and kept the build commands:


mingw32-g++.exe -g -W -O0 -DWIN32 -D_DEBUG -D_LIB  -c src\w2k\hi.cpp -o ..\..\obj\w2k\dbg\src\w2k\hi.o

cmd /c if exist .\..\..\lib\w2k\dbg\lib.a del .\..\..\lib\w2k\dbg\lib.a
ar.exe -r -s .\..\..\lib\w2k\dbg\Lib.a
ar.exe: creating .\..\..\lib\w2k\dbg\lib.a
Output file is .\..\..\lib\w2k\dbg\lib.a with size 5.21 MB

mingw32-g++.exe -W -O0 -DXERCES_STATIC_LIBRARY -D_DEBUG -DWIN32 -D_CONSOLE -DIL_STD -DINTEL -I -I\include -I..\..\.. ..\..\src\w2k -c \src\w2k\hello.cpp -o ..\..\obj\w2k\dbg\src\w2k\hello.o
In file included from /xercesc/validators/datatype/DatatypeValidator.hpp:27:0,
                 from /xercesc/framework/XMLAttr.hpp:28,
                 from /xercesc/framework/XMLDocumentHandler.hpp:28,
                 from /xercesc/parsers/AbstractDOMParser.hpp:26,
                 from /xercesc/parsers/XercesDOMParser.hpp:27,
                 
\src\w2k\r.cpp: In function 'int main(int, char**)':
mingw32-g++.exe -W -O0 -DXERCES_STATIC_LIBRARY -D_DEBUG -DWIN32 -D_CONSOLE -DIL_STD  -DINTEL -I -I\include -I
In file included from /xercesc/validators/datatype/DatatypeValidator.hpp:27:0,
                 from /xercesc/framework/XMLAttr.hpp:28,
                 from /xercesc/framework/XMLDocumentHandler.hpp:28,
                 from /xercesc/parsers/AbstractDOMParser.hpp:26,
                 from /xercesc/parsers/XercesDOMParser.hpp:27,
                 from \src\w2k\hello1.cpp:19:
mingw32-g++.exe -W -O0 -DXERCES_STATIC_LIBRARY -D_DEBUG -DWIN32 -D_CONSOLE -DIL_STD -DINTEL -I -I\include -I
mingw32-c++.exe -L..\..\..\\lib\w2k\dbg -L\lib -Lxerces-c_2_8_0\lib -Lxerces-c_2_8_0\bin -o

 
Regards,
Pradeep

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #8 on: November 11, 2016, 01:12:33 am »
Code: [Select]
mingw32-c++.exe -L..\..\..\\lib\w2k\dbg -L\lib -Lxerces-c_2_8_0\lib -Lxerces-c_2_8_0\bin -o

Did you try linking to the library; because what you posted shows that you did NOT do that?

Tim S.
« Last Edit: November 11, 2016, 01:14:05 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #9 on: November 11, 2016, 02:32:19 pm »
I have decided you must be a troll; because you refuse to post the information needed to help you!

Edit2: You need to decide are you using a Shared(DLL) or static Library; and you need to tell me which you are trying to do!!

Edit: In order to help you I need to know if you defined XERCES_STATIC_LIBRARY or NOT!!!
I need to know after defining or removing the define of  XERCES_STATIC_LIBRARY; that you rebuilt the project.

I need to see the link command with at least one error included!!

Tim S.
« Last Edit: November 11, 2016, 02:49:10 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7012
    • My Best Post
Re: Application linker errors to Xercesc (XML Parser) with g++ compiler
« Reply #10 on: November 12, 2016, 02:31:51 am »
I give up on helping you build a 9 year old version of the library because you are likely doing something wrong; but, figuring out what you did wrong will likely violate the rules of this site. http://forums.codeblocks.org/index.php/topic,9996.0.html

Since, you seem to NOT want to be helped; you never post what I ask for; and it is appearing to be playing 20 questions!
I never like the game; I can NOT help thinking you seemed to be a troll. Esp. after I found out you are trying 9 year old code!!

FYI: If you are NOT a troll you should NOT expect 9 year old code to compile and link with a version of GCC much newer than it!

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org