Search code examples
visual-studiowiresharkwireshark-dissectorlnk2001

Missing libwireshark.def in epan directory


I have created a simple plug-in dissector for wireshark. Building gives LNK2001 error only for the dissector I have written. Common solution suggest adding these functions to libwireshark.def file in epan folder. However, this file doesn't exist at all. What should I do to fix the problem.

here is a part of the given error messages:

'''error LNK2001: unresolved external symbol __imp_prefs_register_uint_preference 1>packet-test.obj : error LNK2001: unresolved external symbol __imp_proto_register_field_array '''


Solution

  • The Wireshark developers changed this a few years ago. If you need to call a function in another dissector that isn't currently exported, the solution used to be to add that function name to libwireshark.def. Now, what you need to do is edit the .h file that declares the function (not the .c file that contains the implementation). Add WS_DLL_PUBLIC to the beginning of the line containing the function you want to make available to your plugin. If it's not already there, also add:

    #include "ws_symbol_export.h"
    

    near the top of the file.

    This diff has an example of making the change: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blobdiff;f=epan/dissectors/packet-tcp.h;h=2351d9b37648fa0df3ae0c3fff6710b005f2f433;hp=f2e7e92a9171b3cf47b2ace2c845afd39ae2d500;hb=1ebdb2e521ca0cbd7aeebd1c89b8a5cf6a4cc322;hpb=0b8d70bfb715bc3d89b6dfae86fc79d7c4387f02