This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

using libxml2 in my own dissector

0

Hello,

I am trying to write my own wireshark plugin. I need to use xml library. I modified Makefile.nmake, added all includes and lib files:

CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
/I../.. $(GLIB_CFLAGS) \
/I$(PCAP_DIR)\include \
/Izlib\include \
/Ilibxml2\include \
/Ilibiconv\include

.c.obj:: $(CC) $(CFLAGS) -Fd.\ -c $<

LDFLAGS = $(PLUGIN_LDFLAGS)

!IFDEF ENABLE_LIBWIRESHARK LINK_PLUGIN_WITH=....\epan\libwireshark.lib CFLAGS=$(CFLAGS)

LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) zlib\lib\zdll.lib LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) libxml2\lib\libxml2.lib LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) libxml2\lib\libxml2_a.lib LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) libxml2\lib\libxml2_a_dll.lib LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) libiconv\lib\libiconv.lib LINK_PLUGIN_WITH=$(LINK_PLUGIN_WITH) libiconv\lib\libcharset.lib

The dissector is a developed as a plugin and runs fine till I added the libxml2 library. After adding libxml2 lib, my dissector is also compiling well, but when I add method which uses libxml2 library and run wireshark I am getting an error:

" Couldn’t load module C:\EWireshark\EWireshark_clean\wireshark-gtk2\plugins\1.99.0\lsd.dll: .. “

What’s more I don’t even use this method anywhere in my plugin. It is only written and looks like that:

void parseMetafile(xmlChar* metafile)
{
xmlDocPtr doc = xmlParseDoc(metafile);
}

After commenting this method out my wireshark plugin works well.

It seems that it is a problem with some libxml2 dependencies, but I have no idea what more should I add to Makefile.nmake to fix this problem.

Is there anything to debug this, or does somebody know what I am doing wrong?

asked 08 Sep ‘14, 02:27

Magda%20Nowak-Trzos's gravatar image

Magda Nowak-…
1335
accept rate: 0%

edited 08 Sep ‘14, 07:46


2 Answers:

1

On Windows, explicit DLL dependencies must be satisfied at load time from the DLL search path, which isn't the same as the command path. The error you've reported is symptomatic of an unmet dependency.

To fix it you will have to copy (or ensure nmake copies) the dependant DLLs somewhere on the DLL search path, the location of your plugin DLL in the 'run' directly is suitable.

To work out the DLLs required (you many need more than one) you can either copy each one in turn as indicated by the error, or use a tool such as 'depends' to list all the dependencies. The libxml docs might also have more on any dependencies.

answered 08 Sep '14, 13:00

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

1

You will need to add these dlls into the directory in which you are running the executable for libxml2 to be loaded correctly:

iconv.dll

libxml2.dll

answered 08 Sep '14, 18:16

Frankie's gravatar image

Frankie
31115
accept rate: 0%

thanks a lot ! iconv.dll was missing

(09 Sep '14, 01:08) Magda Nowak-...