How to get example libxml.bas compile and run?

New to FreeBASIC? Post your questions here.
Post Reply
PeterHu
Posts: 152
Joined: Jul 24, 2022 4:57

How to get example libxml.bas compile and run?

Post by PeterHu »

Greetings!

When I tried to compile example\xml\libxml.bas ,the compiled complaint no -llibxml2 found,so I download libxml2-2.9.3-win32-x86_64.7z ( link in another thread of fb) and put *.a in compiler\lib64 and *.dll in \bin64 and also both *.a & *.dlls in the same folder of this libxml.bas example.Now the compiler complaints:

Code: Select all

Failed Compile (Errors 1  Warnings 0  [2022-10-21  12:36:18])

Command Line: 
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\fbc32.exe -m "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.bas" -v -s console  -x "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.exe"

FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win32 (32bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
target:       win32, 486, 32bit
backend:      gas
compiling:    E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.bas -o E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.asm (main module)
assembling:   E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\as.exe --32 --strip-local-absolute "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.asm" -o "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o"
linking:      E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe -m i386pe -o "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.exe" -subsystem console -T "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32\fbextra.x" --stack 1048576,1048576 -s -L "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32" -L "." "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32\crt2.o" "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32\crtbegin.o" "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32\fbrt0.o" "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o" "-(" -lxml2 -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\lib\win32\crtend.o" 
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x6d): undefined reference to `xmlReaderForFile'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0xab): undefined reference to `xmlTextReaderRead'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0xc3): undefined reference to `xmlTextReaderConstName'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0xd1): undefined reference to `xmlTextReaderConstValue'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0xe1): undefined reference to `xmlTextReaderDepth'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0xf6): undefined reference to `xmlTextReaderNodeType'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x133): undefined reference to `xmlTextReaderIsEmptyElement'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x148): undefined reference to `xmlTextReaderHasValue'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x16d): undefined reference to `xmlTextReaderRead'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x180): undefined reference to `xmlFreeTextReader'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x1b1): undefined reference to `xmlCleanupParser'
E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe: E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.o:fake:(.text+0x1b6): undefined reference to `xmlMemoryDump'
linking failed: 'E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\bin\win32\ld.exe' terminated with exit code 1


Seems I got a wrong library or tried in a totally wrong way.So what's exactly need to do to use libxml in FB?

Thanks in advance for the help.
PaulSquires
Posts: 1002
Joined: Jul 14, 2005 23:41

Re: How to get example libxml.bas compile and run?

Post by PaulSquires »

I just tried it and here is what I had to do:

Go to: http://xmlsoft.org/sources/win32/64bit/

I used the 32-bit Downloads:
(You would have to download the 64-bit versions if that is the DLL's that you wish to use)

iconv-1.14-win32-x86.7z
- extract libiconv-2.dll into the same file as your code source.

libxml2-2.9.3-win32-x86.7z
- extract libxml2-2.dll into the same file as your code source.
- extract libxml2.dll.a into \lib\win32

mingwrt-5.2.0-win32-x86.7z
- extract libwinpthread-1.dll into the same file as your code source.
- extract libgcc_s_dw2-1.dll into the same file as your code source.

zlib-1.2.8-win32-x86.7z
- extract zlib1.dll into the same file as your code source.

Compile your source code and run the resulting EXE from the command line passing the name of the XML file as a parameter.
libxml.exe test.xml

This worked for me but that's a lot of libraries to install just for XML. The issue is that the Windows port of XML does not have many of the systems DLL's that other operating systems would have installed by default. There is probably a better way to do all of this but this worked for me. Maybe you could copy the files to shared folders existign in your PATH if you want to reuse them for multiple projects.

Good luck!
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: How to get example libxml.bas compile and run?

Post by caseih »

PeterHu wrote: Oct 21, 2022 4:45When I tried to compile example\xml\libxml.bas ,the compiled complaint no -llibxml2 found,so I download libxml2-2.9.3-win32-x86_64.7z ( link in another thread of fb) and put *.a in compiler\lib64 and *.dll in \bin64 and also both *.a & *.dlls in the same folder of this libxml.bas example.Now the compiler complaints:

E:\Learning\FreeBasic\WinFBE\Toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\fbc32.exe -m "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.bas" -v -s console -x "E:\Learning\FreeBasic\WinFBE\toolchains\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\examples\xml\libxml.exe"

FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win32 (32bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
backend: gas

Seems I got a wrong library or tried in a totally wrong way.So what's exactly need to do to use libxml in FB?
You are using a 32-bit compiler but you downloaded a 64-bit dll. That's not going to work.
PeterHu
Posts: 152
Joined: Jul 24, 2022 4:57

Re: How to get example libxml.bas compile and run?

Post by PeterHu »

Hi both,

It works now.Thanks a lot.
Post Reply