From 63435f5616133abe25c8f9b4f09ea220046e2af4 Mon Sep 17 00:00:00 2001 From: mrbubble62 Date: Tue, 14 Feb 2017 01:43:14 -0500 Subject: [PATCH 1/3] hackrf_sweep on Windows added precompiled fftw-3.3.5 --- host/README.md | 11 ++++++++--- host/cmake/modules/FindFFTW.cmake | 8 ++++++++ host/hackrf-tools/src/CMakeLists.txt | 3 +++ host/hackrf-tools/src/hackrf_sweep.c | 5 ++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/host/README.md b/host/README.md index 5efd28f6..a0af41e8 100644 --- a/host/README.md +++ b/host/README.md @@ -63,11 +63,16 @@ make install ###For Visual Studio 2015 x64 ``` c:\hackrf\host\build> cmake ../ -G "Visual Studio 14 2015 Win64" \ --DLIBUSB_INCLUDE_DIR=c:\libusb-1.0.18-win\include\libusb-1.0 \ --DLIBUSB_LIBRARIES=c:\libusb-1.0.18-win\MS64\static\libusb-1.0.lib \ +-DLIBUSB_INCLUDE_DIR=c:\libusb-1.0.21\libusb \ +-DLIBUSB_LIBRARIES=c:\libusb-1.0.21\x64\Release\lib\libusb-1.0.lib \ -DTHREADS_PTHREADS_INCLUDE_DIR=c:\pthreads-w32-2-9-1-release\Pre-built.2\include \ --DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64\pthreadVC2.lib +-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64\pthreadVC2.lib \ +-DFFTW_INCLUDES=C:\hackrf-2017.02.1\host\hackrf-tools\fftw-3.3.5-dll64 \ +-DFFTW_LIBRARIES=C:\hackrf-2017.02.1\host\hackrf-tools\fftw-3.3.5-dll64\libfftw3f-3.lib ``` +unpack precompiled fftw-3.3.5-dll64.zip from http://www.fftw.org/install/windows.html to C:\hackrf-2017.02.1\host\hackrf-tools\fftw-3.3.5-dll64 +Create library from VS command shell +C:\hackrf-2017.02.1\host\hackrf-tools\fftw-3.3.5-dll6> lib /machine:x64 /def:libfftw3f-3.def Cmake will produce a solution file named `hackrf_all.sln` and a series of project files which can be used with msbuild as follows: diff --git a/host/cmake/modules/FindFFTW.cmake b/host/cmake/modules/FindFFTW.cmake index 00c3401c..b9f3bfb8 100644 --- a/host/cmake/modules/FindFFTW.cmake +++ b/host/cmake/modules/FindFFTW.cmake @@ -12,7 +12,15 @@ endif (FFTW_INCLUDES) find_path (FFTW_INCLUDES fftw3.h) +IF (WIN32) +include_directories(${FFTW_INCLUDES}) +find_library (FFTW_LIBRARIES NAMES ${FFTW_LIBRARIES}) +ELSE(WIN32) find_library (FFTW_LIBRARIES NAMES fftw3) +ENDIF(WIN32) + + + # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if # all listed variables are TRUE diff --git a/host/hackrf-tools/src/CMakeLists.txt b/host/hackrf-tools/src/CMakeLists.txt index d9938846..c2e27c0a 100644 --- a/host/hackrf-tools/src/CMakeLists.txt +++ b/host/hackrf-tools/src/CMakeLists.txt @@ -31,12 +31,15 @@ SET(TOOLS hackrf_cpldjtag hackrf_info hackrf_debug + hackrf_sweep ) if(MSVC) add_library(libgetopt_static STATIC ../getopt/getopt.c ) + LIST(APPEND TOOLS_LINK_LIBS ${FFTW_LIBRARIES}) + include_directories(${FFTW_INCLUDES}) else() pkg_check_modules(FFTW REQUIRED fftw3f) LIST(APPEND TOOLS hackrf_sweep) diff --git a/host/hackrf-tools/src/hackrf_sweep.c b/host/hackrf-tools/src/hackrf_sweep.c index 5f7fd823..f788925e 100644 --- a/host/hackrf-tools/src/hackrf_sweep.c +++ b/host/hackrf-tools/src/hackrf_sweep.c @@ -47,7 +47,7 @@ typedef int bool; #ifdef _WIN32 #include - +#define M_PI 3.14159265358979323846264338327950288 #ifdef _MSC_VER #ifdef _WIN64 @@ -517,6 +517,9 @@ int main(int argc, char** argv) { } fd = fopen(path, "wb"); + if (fd == NULL) { + fd = fopen("nul", "wb"); + } if( fd == NULL ) { fprintf(stderr, "Failed to open file: %s\n", path); return EXIT_FAILURE; From e4106f5acabbcdc726d9984125ae8f3912f0b477 Mon Sep 17 00:00:00 2001 From: mrbubble62 Date: Wed, 15 Feb 2017 01:01:09 -0500 Subject: [PATCH 2/3] Cleaned up --- host/hackrf-tools/src/hackrf_sweep.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_sweep.c b/host/hackrf-tools/src/hackrf_sweep.c index f788925e..97f66408 100644 --- a/host/hackrf-tools/src/hackrf_sweep.c +++ b/host/hackrf-tools/src/hackrf_sweep.c @@ -20,6 +20,7 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ +#define _USE_MATH_DEFINES #include @@ -47,7 +48,6 @@ typedef int bool; #ifdef _WIN32 #include -#define M_PI 3.14159265358979323846264338327950288 #ifdef _MSC_VER #ifdef _WIN64 @@ -334,7 +334,11 @@ void sigint_callback_handler(int signum) { int main(int argc, char** argv) { int opt, i, result = 0; +#ifdef _WIN32 + const char* path = "nul"; +#else const char* path = "/dev/null"; +#endif const char* serial_number = NULL; int exit_code = EXIT_SUCCESS; struct timeval t_end; @@ -517,9 +521,6 @@ int main(int argc, char** argv) { } fd = fopen(path, "wb"); - if (fd == NULL) { - fd = fopen("nul", "wb"); - } if( fd == NULL ) { fprintf(stderr, "Failed to open file: %s\n", path); return EXIT_FAILURE; From 1ba64c674cf402d0d930e47d6e45a5fb49c94b65 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Wed, 15 Feb 2017 08:56:19 -0700 Subject: [PATCH 3/3] do not add hackrf_sweep to cmake list twice --- host/hackrf-tools/src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/host/hackrf-tools/src/CMakeLists.txt b/host/hackrf-tools/src/CMakeLists.txt index c2e27c0a..0d223ead 100644 --- a/host/hackrf-tools/src/CMakeLists.txt +++ b/host/hackrf-tools/src/CMakeLists.txt @@ -42,7 +42,6 @@ if(MSVC) include_directories(${FFTW_INCLUDES}) else() pkg_check_modules(FFTW REQUIRED fftw3f) - LIST(APPEND TOOLS hackrf_sweep) LIST(APPEND TOOLS_LINK_LIBS m fftw3f) endif()