Open raffaeler opened 9 months ago
I suggest opening a PR to update the documentation!
I suggest opening a PR to update the documentation!
I can do it, but I saw the backlog and decided to wait for better times :)
It should be possible to do this with a bit less work!
It's possible to install the dependencies in one command using vcpkg:
vcpkg install --triplet=x64-windows libusb fftw3 pthreads
Unfortunately it still seems to be necessary to tell cmake
where everything was installed, with something like:
cmake ..
-DLIBUSB_INCLUDE_DIR=C:/vcpkg/installed/x64-windows/include/libusb-1.0
-DLIBUSB_LIBRARIES=C:/vcpkg/installed/x64-windows/lib/libusb-1.0.lib
-DFFTW_INCLUDES=C:/vcpkg/installed/x64-windows/include
-DFFTW_LIBRARIES=C:/vcpkg/installed/x64-windows/lib/fftw3f.lib
-DTHREADS_PTHREADS_INCLUDE_DIR=C:/vcpkg/installed/x64-windows/include
-DTHREADS_PTHREADS_WIN32_LIBRARY=C:/vcpkg/installed/x64-windows/lib/pthreadvc3.lib
(I'd like to get things tweaked so that cmake will discover these paths automatically if the relevant vcpkg variables are set.)
But then it should be possible to just cmake --build . --config Release
See also @dmaltsiniotis' work on #1391.
@martinling My first wish is changing all the libraries to be statically linked so that you don't have to bring dlls with you. That's not hard but I did not want to recompile fftw (apparently they do not provide static libs) or make changes to the cmake files.
These updated instructions are a very nice source of information for newcomers. Apart from this open issue, is that information part of any document? It seems to differ from https://hackrf.readthedocs.io/en/latest/
These updated instructions are a very nice source of information for newcomers. Apart from this open issue, is that information part of any document? It seems to differ from https://hackrf.readthedocs.io/en/latest/
I wrote it by myself. Years ago I had to build myself the dependencies. Also, previous versions of VS required different steps. Nowadays, all the major C++ compilers adhere to the recent standards and building x-plat has become simpler. I just hope this can be useful to the community.
Hello everyone and excuse me for the question... but isn't there somewhere hackrf.dll and the hackrf tools already compiled for Windows in the latest version (2024.02.1?), ready to be used? I would like to use them without having to create them myself with CMake etc... I would have expected to find them in the Releases Assets here in GitHub, but I didn't find them.
Thanks in advance Francesco
Hi @FrankBolleri, as it turns out, yes there is. You can download pre-compiled Windows binaries of the DLL and tools from the nightly build process. The most recent run is located here: https://github.com/greatscottgadgets/hackrf/actions/runs/11778239935 and the link to download is at the bottom of the page:
Cheers, -DM
Hi @FrankBolleri, as it turns out, yes there is. You can download pre-compiled Windows binaries of the DLL and tools from the nightly build process. The most recent run is located here: https://github.com/greatscottgadgets/hackrf/actions/runs/11778239935 and the link to download is at the bottom of the page:
Cheers, -DM
Thank you very much! Have a nice day!
This is not a request. I just decided to post here the detailed and updated instructions to compile all the sources on a Windows machine. I added boring and obvious details which may anyway be useful for people not used to compile C++ sources on Windows.
I may create a pull-request, if Michael expresses the interest.
How to compile
HackRF
on WindowsThe first requirement (for this guide) is to install Visual Studio.
The second requirement is to install
CMake
from: https://cmake.org/download/. I tested my guide with the version3.28.3
. When installing, I recommend to select the option that addsCMake
into the user'spath
environment variable.Note: It's totally possible to use
Visual Studio 2022
as well. You can also use the VS2022 IDE with the VS2019 C++ libraries. The Visual Studio installer gives you the possibility to install both.After installing these two requirements, open a
developer command prompt
(a shortcut prepared by the Visual Studio installer). Be advised to open the command prompt only after completing the installation, as the environment variables are never updated in existing processes like the command prompt.Required libraries
Download and extract the following libraries inside the
c:\libs
folder.You can use any folder, just carefully change the root folder in the batch files as well.
libusb
: https://github.com/libusb/libusb/releases (current version: 1.0.27)pthreads
: https://sourceforge.net/projects/pthreads4w/files/ (pthreads-w32-2-9-1-release.zip)fftw
: https://www.fftw.org/install/windows.html (fftw-3.3.5-dll64.zip )fftw
does not provide a pre-built static library. This means that you will need to:dll
file within the folder of theexe
tools.Create the stub lib for
fftw
From the
developer command prompt
for Visual Studio 2019. Be advised to use the same version of the command prompt of the compiler that you are going to use.These are not required, but just in case:
Clone the
HackRF
repositoryThe first step is to clone the sources from the GitHub repository.
Then create the build folder inside the
hackrf
root folder:The newly created build folder is used to host the
CMake
generated artifacts.Now create the following two batch files inside the
build
folder.Batch 1:
mymake.cmd
This batch file does uses Visual Studio 2019 to compile the solution. The options are:
-G "Visual Studio 16 2019"
-A "x64"
Previous
CMake
releases usedWin64
string-DCMAKE_BUILD_TYPE=Release
-DLIBUSB_INCLUDE_DIR=c:\libs\libusb-1.0.27\include
libusb
-DLIBUSB_LIBRARIES=c:\libs\libusb-1.0.27\VS2019\MS64\static\libusb-1.0.lib
libusb
static library-DTHREADS_PTHREADS_INCLUDE_DIR=c:\libs\pthreads-w32-2-9-1-release\Pre-built.2\include
pthreads
-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\libs\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64\pthreadVC2.lib
pthreads
static library-DFFTW_INCLUDES=c:\libs\fftw-3.3.5-dll64
fftw
-DFFTW_LIBRARIES=c:\libs\fftw-3.3.5-dll64\libfftw3f-3.lib
fftw
stub libraryBatch 2:
mycompile.cmd
This batch does the following:
hackrf.lib
,hackrf.dll
,hackrf_static.lib
hackrf.dll
to the tools target binary folderhackrf.dll
into the tools target binary folderlibfftw3f-3.dll
into the tools target binary folderCompile
Run
mymake.cmd
to generate theCMake
artifacts. Ensure you don't see any errors before proceding.Finally run
mycompile.cmd
to compile the sources and copy the required libraries to the tools target folder.Generated binaries
All the binaries are generated in these folders:
hackrf\host\build\libhackrf\src\Release
hackrf\host\build\hackrf-tools\src\Release