CMake steps for C dissector 2.4 -> 2.6 migration? (e.g. linker errors)
I have a Wireshark 2.4 private dissector plugin written in C which is running like a charm. Now that Wireshark 2.6 is out, I want to upgrade my source code to support the new version, but I'm quite struggling with the transition. Is there a guide or "developer release notes" that I can read to get the changes and use to adjust my code and build configuration to match the new standard?
I already solved some problems with comparing to other dissectors, but I can't solve this: During compilation I get this linker error:
packet-protocolname.obj : error LNK2019: unresolved external symbol __imp_proto_register_protocol referenced in function proto_register_protocolname
From other dissectors I see that there wireshark.lib, wiretap.lib, wsutil.lib are included in linker, but not in my dissector. If I want to add them to my dissector using these lines in my CMakeLists.txt:
target_link_libraries(../../../run/$(ConfigurationName)/wireshark.lib)
target_link_libraries(../../../run/$(ConfigurationName)/wiretap.lib)
target_link_libraries(../../../run/$(ConfigurationName)/wsutil.lib)
I get this error message:
> Cannot specify link libraries for target
> "../../../run/$(ConfigurationName)/wireshark.lib" which is not built by this project.
This is my current CMakeLists.txt:
include(WiresharkPlugin)
# Plugin name and version info (major minor micro extra)
set_module_info(protocolname 0 1 2 3)
set(DISSECTOR_SRC
packet-protocolname.c
)
set(PLUGIN_FILES
${DISSECTOR_SRC}
)
set(CLEAN_FILES
${PLUGIN_FILES}
)
if (WERROR_COMMON_FLAGS)
set_source_files_properties(
${CLEAN_FILES}
PROPERTIES
COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(some/directory/i/need)
set(CUSTOM_DISSECTOR_SRC
${DISSECTOR_SRC}
)
add_plugin_library(protocolname protocolname)
get_filename_component(_dll_output_dir "${_libwireshark_location}" PATH)
file (TO_NATIVE_PATH "${_dll_output_dir}" _dll_output_dir_win )
add_custom_command(TARGET protocolname PRE_BUILD
[... some command I need]
)
install(TARGETS protocolname
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins/${CPACK_PACKAGE_VERSION}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins/${CPACK_PACKAGE_VERSION}
)
file(GLOB DISSECTOR_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
CHECKAPI(
NAME
protocolname
SWITCHES
-g abort -g termoutput -build
SOURCES
${DISSECTOR_SRC}
${DISSECTOR_HEADERS}
)
I'm on Windows, switched from Wireshark 2.4 (Visual Studio 2013) to Wireshark 2.6 (Visual Studio 2017)
Thanks in advance!
Your CMakeLists.txt seems to have a lot of unnecessary additions. Try using the CMakeLists.txt of an existing plugin, e.g. Gryphon as a basis and change the names, the source files, and add plugin-specific external (non-wireshark) includes and libraries. CMake will handle the Wireshark ones.
Thanks grahamb for your response. I don't have any unneccessary addition, I started with CMakeLists.txt from Gryphon as written in the manual. What you think of "unnecessary additions" are the examples written there ;)
See my answer below for the changes I had to do to comply to 2.6 standard.