Skip to content

Commit 61198f7

Browse files
committed
Adding more support for windows builds
1 parent 8819a86 commit 61198f7

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ SET(GLIB2_INCLUDE_DIRS $ENV{WIRESHARK_INCLUDE_DIRS})
5151
ENDIF()
5252
include_directories (${WIRESHARK_INCLUDE_DIRS})
5353

54+
IF(DEFINED WIRESHARK_LIB_DIR)
55+
link_directories (${WIRESHARK_LIB_DIR})
56+
ENDIF()
57+
5458
IF(NOT DEFINED GCRYPT_INCLUDE_DIR)
5559
find_package(Gcrypt)
5660
ELSE()
@@ -61,7 +65,6 @@ include_directories (${GCRYPT_INCLUDE_DIR})
6165
set(LINK_MODE_LIB SHARED)
6266
set(LINK_MODE_MODULE MODULE)
6367

64-
6568
set(DISSECTOR_SRC
6669
packet-whatsapp.c
6770
whatsapp-proto.cc
@@ -101,7 +104,7 @@ set_target_properties(whatsapp PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
101104
IF(DEFINED MANUAL_LINK)
102105
target_link_libraries(whatsapp)
103106
ELSE()
104-
target_link_libraries(whatsapp gcrypt)
107+
target_link_libraries(whatsapp wireshark gcrypt glib-2.0)
105108
ENDIF()
106109

107110
install(TARGETS whatsapp
@@ -118,9 +121,24 @@ IF(DEFINED STATIC_GCC_BUILD)
118121
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
119122
ENDIF()
120123

124+
if (WIN32)
125+
if(MINGW)
126+
message(STATUS "Compiling with MINGW!")
127+
# Static link
128+
set(CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -lpthread")
129+
endif(MINGW)
130+
endif (WIN32)
131+
132+
if (WIN32)
133+
add_custom_command(TARGET whatsapp
134+
POST_BUILD
135+
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.dll
136+
)
137+
ELSE()
121138
add_custom_command(TARGET whatsapp
122139
POST_BUILD
123140
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.so
124141
)
142+
ENDIF()
125143

126144

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ You need the wireshark headers, the glib-2.0 headers, the libcrypto headers (ins
2323
For Windows build:
2424

2525
1. Create a build directory and move to it, for example "mkdir build; cd build"
26-
2. Generate Makefile 'LDFLAGS="/path/libglib-2.0-0.dll /path/libwireshark.dll" cmake -D GNU_HOST=i686-w64-mingw32 -D STATIC_GCC_BUILD=1 ..'. Be sure to properly set the cross-compiler prefix and specify the proper paths to the libraries.
27-
3. Now build the plugin "make"
28-
4. And the plugin should be built as "whatsapp.so", just copy it to the plugins folder "C:\Program Files\Wireshark\Plugins\'version'\whatsapp.dll"
26+
2. Tweak mingw32-windows.toolchain according to your needs.
27+
3. Generate Makefile "cmake -DCMAKE_TOOLCHAIN_FILE=../mingw32-windows.toolchain .." (set WIRESHARK_INCLUDE_DIRS, GCRYPT_INCLUDE_DIR variables if needed)
28+
4. Now build the plugin "make"
29+
5. And the plugin should be built as "whatsapp.dll", just copy it to the plugins folder "C:\Program Files\Wireshark\Plugins\'version'\whatsapp.dll"
30+
31+
You will probably need libglib-2.0, libwireshark and libgcrypt to properly link the DLL.
2932

3033
Windows builds are currently under test, report any bugs you find please.
3134

mingw32-windows.toolchain

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# the name of the target operating system
2+
SET(CMAKE_SYSTEM_NAME Windows)
3+
4+
# which compilers to use for C and C++
5+
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
6+
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
7+
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
8+
9+
# here is the target environment located
10+
SET(CMAKE_FIND_ROOT_PATH /home/david/mingw/mingw-w64-i686/ )
11+
12+
# adjust the default behaviour of the FIND_XXX() commands:
13+
# search headers and libraries in the target environment, search
14+
# programs in the host environment
15+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 commit comments

Comments
 (0)