CMake issues using Python.h inside dissector
Hi,
I want to call a function from a Python library inside a dissector (I know, not great but I'm just trying something out). To do this I'm using the Python/C api.
After adding the #include in the dissector I wanted to modify, Python.h was not found. This I solved by adding to the epan/dissectors/CMakeLists.txt
file (around line 2194):
target_include_directories(dissectors
SYSTEM PRIVATE
+ ${Python3_INCLUDE_DIRS}
Now I get linker errors, so I tried adding a
+target_link_libraries(dissectors ${Python3_LIBRARIES})
right after the target_include_directories
(still in epan/dissectors/CMakeLists.txt
).
That still didn't work, and I don't know how to get the linker to link the Python libraries correctly? I'm not very experienced with CMake and even less with Wireshark development.
This is the linker error I get:
...
[ 90%] Linking CXX executable run/wireshark
ld: run/libwireshark.so.0.0.0: undefined reference to `PyRun_SimpleStringFlags'
ld: run/libwireshark.so.0.0.0: undefined reference to `Py_FinalizeEx'
ld: run/libwireshark.so.0.0.0: undefined reference to `Py_Initialize'
I tried that too, it didn't work :(