Merge pull request #47 from hayguen/development

bugfix and static build options
development
Lucas Teske 2017-04-09 13:24:37 -03:00 committed by GitHub
commit 769da46da8
4 changed files with 43 additions and 2 deletions

View File

@ -57,6 +57,22 @@ if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
add_definitions(-fvisibility=hidden)
endif()
OPTION(RTL_STATIC_BUILD "Build rtl-tools static (except RTLSDR.DLL) on MinGW/Win32" ON)
if(RTL_STATIC_BUILD)
if (WIN32)
if(MINGW)
# Special MINGW stuff here
# see https://cmake.org/pipermail/cmake/2012-September/051970.html
# see http://stackoverflow.com/questions/13768515/how-to-do-static-linking-of-libwinpthread-1-dll-in-mingw
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
endif()
endif()
endif()
#########################################################################
# Bug Fix
#########################################################################

View File

@ -682,7 +682,7 @@ int main(int argc, char **argv)
bind(s,(struct sockaddr *)&local,sizeof(local));
#ifdef _WIN32
ioctlsocket(listensocket, FIONBIO, &blockmode);
ioctlsocket(s, FIONBIO, &blockmode);
#else
r = fcntl(s, F_GETFL, 0);
r = fcntl(s, F_SETFL, r | O_NONBLOCK);

View File

@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 2.8)
# edit this path
SET( LIBUSBBASE C:/src/_foreign/libusb-1.0.20 )
OPTION(RTL_FULL_STATIC_BUILD "Build rtl-tools fully static." OFF)
OPTION(RTL_FULL_STATIC_BUILD "Build rtl-tools fully static." ON)
if(RTL_FULL_STATIC_BUILD)
if (WIN32)
@ -86,6 +86,9 @@ target_link_libraries( rtl_tcp ${LIBUSB} ${SOCKLIBS} )
add_executable( rtl_udp ../src/rtl_udp.c ${RTLLIBFILES} )
target_link_libraries( rtl_udp ${LIBUSB} ${SOCKLIBS} )
add_executable( rtl_sdr ../src/rtl_sdr.c ${RTLLIBFILES} )
target_link_libraries( rtl_sdr ${LIBUSB} )
add_executable( rtl_adsb ../src/rtl_adsb.c ${RTLLIBFILES} )
target_link_libraries( rtl_adsb ${LIBUSB} )
@ -94,3 +97,13 @@ target_link_libraries( rtl_power ${LIBUSB} )
add_executable( rtl_ir ../src/rtl_ir.c ${RTLLIBFILES} )
target_link_libraries( rtl_ir ${LIBUSB} )
add_executable( rtl_eeprom ../src/rtl_eeprom.c ${RTLLIBFILES} )
target_link_libraries( rtl_eeprom ${LIBUSB} )
if (NOT WIN32)
# errors at compilation with MinGW, e.g. missing include sys/select.h
add_executable( rtl_rpcd ../src/rtl_rpcd.c ../src/rtlsdr_rpc_msg.c ${RTLLIBFILES} )
target_link_libraries( rtl_rpcd ${LIBUSB} )
endif()

View File

@ -29,3 +29,15 @@ the resulting executables have no other dependencies than libwinpthread-1.dll
from the MINGW system at C:\Qt\Qt5.5.1\Tools\mingw492_32\bin\
or C:\Qt\Qt5.5.1\5.5\mingw492_32\bin
=======================================================================
opening main CMakeLists.txt in root (above win32-qtcreator) with above QT 5.5/qtcreator
set RTL_STATIC_BUILD = ON
set LIBUSB_FOUND = TRUE
set LIBUSB_INCLUDE_DIR = C:/src/_foreign/libusb-1.0.20/include/libusb-1.0
set LIBUSB_LIBRARIES = C:/src/_foreign/libusb-1.0.20/MinGW32/static/libusb-1.0.a
set THREADS_PTHREADS_INCLUDE_DIR = C:/Qt/Qt5.6.1/Tools/mingw492_32/i686-w64-mingw32/include
set THREADS_PTHREADS_WIN32_LIBRARY = C:/Qt/Qt5.6.1/Tools/mingw492_32/i686-w64-mingw32/lib/libwinpthread.a
the resulting executables have no other dependencies, except the freshly built librtlsdr.dll