AI-Powered Cyberattacks: How to Detect, Prevent & Defend Against Intelligent Threats

Read Now
We utilize artificial intelligence for site translations, and while we strive for accuracy, they may not always be 100% precise. Your understanding is appreciated.

Installing the Lib::XML Perl Module on Microsoft Windows

Share this Post

Perl is one of my favorite scripting languages for quickly automating small tasks. For better or for worse, it's still my go to language when I need to do something quick and dirty like parsing XML and sending an email based on the results (just try doing that in a batch file!). Using XPath and the Lib:XML Perl module I can parse anything out of an XML file instantly. Unfortunately, the more recent versions of ActiveState Perl on Windows platforms don't come with a Lib::XML module for you to download so you have to compile it yourself. It wasn't as straightforward as with other modules since Lib::XML has several dependencies and seems to be mostly maintained with Linux users in mind. For easy-to-follow instructions on installing Lib::XML Perl Module on Microsoft Windows, please refer to the steps below.

Lib::XML on ActiveState Perl 5.20 Install Steps

Environment
Windows 7 Pro 64-bit
ActivePerl-5.20.1.2000-MSWin32-x64-298557

1. Download LibXML Win32 64 bit binaries
http://www.zlatkovic.com/libxml.en.html

iconv = iconv-1.14-win32-x86_64.7z
zlib = zlib-1.2.8-win32-x86_64.7z
libxml2 = libxml2-2.9.2-win32-x86_64.7z

2. Download gettext-tools 64 bit binaries
http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/gettext-tools-dev_0.18.1.1-2_win64.zip

3. Download Lib::XML

https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0118.tar.gz

4.Copy the 5 packages to a working directory
For example:

C:\perl_libxml\gettext-tools-dev_0.18.1.1-2_win64.zip
C:\perl_libxml\iconv-1.14-win32-x86_64.7z
C:\perl_libxml\libxml2-2.9.2-win32-x86_64.7z
C:\perl_libxml\XML-LibXML-2.0117.tar.gz
C:\perl_libxml\zlib-1.2.8-win32-x86_64.7z

5.Extract everything out into nice directories here.
When finished there should be 5 folders for each package. Inside each folder should be the all the bin/lib/source stuff.

For example:
C:\perl_libxml\gettext\lib
C:\perl_libxml\iconv\lib
C:\perl_libxml\libxml2\lib
C:\perl_libxml\XML-LibXML\lib
C:\perl_libxml\zlib\lib
...etc...

6. Create another folder called "merged"
For example:
C:\perl_libxml\merged

7. Merge the contents of gettext, iconv, libxml2 & zlib into this new folder.
For example:
C:\perl_libxml\merged\lib\libgettextlib.dll.a
C:\perl_libxml\merged\lib\libiconv.dll.a
C:\perl_libxml\merged\lib\libxml2.dll.a
C:\perl_libxml\merged\lib\libz.a

8. Move the libxml folder up one directory
Located in C:\perl_libxml\merged\include\libxml2, cut it, go up, paste it.

When done with this step the following path should exist:
C:\perl_libxml\merged\include\libxml\c14n.h

9. Install dmake
ppm install dmake

10. Install MinGW
ppm install MinGW

11. Install Dependencies
ppm install XML::NamespaceSupport
ppm install XML::SAX

12. Rename libz to zlib
libz.a -> zlib.a

13. Create the make file
Open a command line & Navigate to C:\perl_libxml\XML-LibXML
Run the command:

> Makefile.PL INC=-IC:\perl_libxml\merged\include LIBS=-LC:\perl_libxml\merged\lib

14. Run dmake

(errors out at the end)

15. Remove the static libXML library
Rename libxml2.a => _libxml2.a

16. Create the make file again
Makefile.PL INC=-IC:\perl_libxml\merged\include LIBS=-LC:\perl_libxml\merged\lib

17. Run dmake again
(Success!)

18. Run dmake test
(Success!)
Files=70, Tests=2503, 16 wallclock secs ( 0.53 usr + 0.16 sys = 0.69 CPU) Result: PASS

19. Run dmake install
Now you can run whatever script to test that it works.

Hopefully, the above steps will make installing Lib::XML Perl on a Windows device a little less time-consuming. Now you can easily analyze an XML file!

Stay Up-to-Date With OPSWAT!

Sign up today to receive the latest company updates, stories, event info, and more.