Skip to content

Commit

Permalink
Adding more support for windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgfnet committed Apr 29, 2015
1 parent 8819a86 commit 61198f7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ SET(GLIB2_INCLUDE_DIRS $ENV{WIRESHARK_INCLUDE_DIRS})
ENDIF()
include_directories (${WIRESHARK_INCLUDE_DIRS})

IF(DEFINED WIRESHARK_LIB_DIR)
link_directories (${WIRESHARK_LIB_DIR})
ENDIF()

IF(NOT DEFINED GCRYPT_INCLUDE_DIR)
find_package(Gcrypt)
ELSE()
Expand All @@ -61,7 +65,6 @@ include_directories (${GCRYPT_INCLUDE_DIR})
set(LINK_MODE_LIB SHARED)
set(LINK_MODE_MODULE MODULE)


set(DISSECTOR_SRC
packet-whatsapp.c
whatsapp-proto.cc
Expand Down Expand Up @@ -101,7 +104,7 @@ set_target_properties(whatsapp PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
IF(DEFINED MANUAL_LINK)
target_link_libraries(whatsapp)
ELSE()
target_link_libraries(whatsapp gcrypt)
target_link_libraries(whatsapp wireshark gcrypt glib-2.0)
ENDIF()

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

if (WIN32)
if(MINGW)
message(STATUS "Compiling with MINGW!")
# Static link
set(CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -lpthread")
endif(MINGW)
endif (WIN32)

if (WIN32)
add_custom_command(TARGET whatsapp
POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.dll
)
ELSE()
add_custom_command(TARGET whatsapp
POST_BUILD
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded whatsapp.so
)
ENDIF()


9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ You need the wireshark headers, the glib-2.0 headers, the libcrypto headers (ins
For Windows build:

1. Create a build directory and move to it, for example "mkdir build; cd build"
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.
3. Now build the plugin "make"
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"
2. Tweak mingw32-windows.toolchain according to your needs.
3. Generate Makefile "cmake -DCMAKE_TOOLCHAIN_FILE=../mingw32-windows.toolchain .." (set WIRESHARK_INCLUDE_DIRS, GCRYPT_INCLUDE_DIR variables if needed)
4. Now build the plugin "make"
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"

You will probably need libglib-2.0, libwireshark and libgcrypt to properly link the DLL.

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

Expand Down
17 changes: 17 additions & 0 deletions mingw32-windows.toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)

# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /home/david/mingw/mingw-w64-i686/ )

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 comments on commit 61198f7

Please sign in to comment.