Hey list,
I’ve got gnuradio building native on windows with MS visual studio using
cmake to generate the project file. Its not the whole gnuradio, just
gruel, gnuradio-core, and qtgui; as a demonstration.
I’d like to go over how to build, and some of the code changes that made
this possible.
Here is a screen cap for the quick preview. Its the qtgui waterfall:
http://i.imgur.com/iGPs3.png
– Grab the source code
Checkout the msvc branch on jblum.git
http://gnuradio.org/cgit/jblum.git/log/?h=msvc
– Install the dependencies
cmake, gsl, fftw, qt, python, numpy, swig, cppunit can be found
pre-built in zip files or exe installers
http://i.imgur.com/ynBha.png
qwt must be built from source once qt installed (see readme)
I could not find a pre-built guile, so I just installed it from cygwin
and added c:\cywgin\bin to my PATH
Of course, you dont need to install half these components if you dont
need swig or qt related stuff.
– Setup the environment variables
All of the installed packages will need to have their bin and lib
directories added to the PATH so they can be found at runtime. While
you’re at it, set the PYTHONPATH and PATH for the gnuradio install.
I recommend using rapid environment editor (vs the 40 character entry
box) so your eyes don’t bleed. Here is a screen cap of the PATHS all
setup on my system:
– Configure the project
Open cmake-gui and feed it the paths for the gnuradio source tree and a
path for the generated build file stuff. Click configure.
What happens next is an iterative process and you will wish there was
package config Set the *_INCLUDE_DIRS and *_LIBRARIES variables for
various dependencies. As you set these variables and click configure,
check boxes for gnuradio components will appear once their dependencies
are met.
Here is a screen cap of my gnuradio configuration fully completed:
http://i.imgur.com/vOrOp.png
When you are satisfied, click configure if anything is in the red, and
then click generate. This will make a visual studio project file.
– Build, test, install…
Open the gnuradio.sln
NOTE: Set the build mode to Release. Don’t mix debug and release
libraries. Many of the dependencies are built for Release mode only. If
you are going to build debug, make sure that all dependency libraries
are debug libraries. This includes python (if you want python support).
Right click on the BUILD_ALL target, click build
http://i.imgur.com/TRls9.png
Unit testing should work, right click on RUN TESTS, click build:
http://i.imgur.com/C8CdG.png
And to install, right click on INSTALL, click build.
– CMake related stuff.
If anyone is interested check out the CMakeLists.txt in gruel,
gnuradio-core, and gr-qtgui directories. Each component knows how to
check for its dependencies and register itself as a component.
Look at the gr-qtgui/src/lib/CMakeLists.txt as an example of a typical
component with swig + python. The gnuradio-core one can be a bit
daunting.
Theres also a modules directory that defines some functions and package
finding. The Gr* files define common-use functions for dealing with
python, swig, testing. The Find* files were snagged of the internet and
mucked up a bit to help deal with finding the dependencies when
pkg-config is not present.
http://gnuradio.org/cgit/jblum.git/tree/Modules?h=msvc
– The code, what changed?
- This was by far the hardest part. When building with MSVC, its
necessary to specify the linkage in header files when declaring things
like class, structs, and functions.
To accomplish this, I created a header for each component that defines a
symbol export macro; And added this macro to the various header files
that needed it (in an automated fashion). Heres what they look like:
http://gnuradio.org/cgit/jblum.git/tree/gruel/src/include/gruel/api.h?h=msvc
http://gnuradio.org/cgit/jblum.git/tree/gnuradio-core/src/lib/general/gr_core_api.h?h=msvc
http://gnuradio.org/cgit/jblum.git/tree/gr-qtgui/src/lib/gr_qtgui_api.h?h=msvc
And an example of this macro in use:
http://gnuradio.org/cgit/jblum.git/tree/gnuradio-core/src/lib/general/gr_agc2_ff.h?h=msvc#n32
- Some source files used non-standard functions; most revolving around
IO or math. The the easiest way to work around this was to make some
compatibility headers for these sources to include:
http://gnuradio.org/cgit/jblum.git/tree/gnuradio-core/src/lib/general/gr_math_compat.h?h=msvc
http://gnuradio.org/cgit/jblum.git/tree/gnuradio-core/src/lib/io/gr_io_compat.h?h=msvc
- There is a small collection of missing header files.
http://gnuradio.org/cgit/jblum.git/tree/msvc_compat?h=msvc
– OK, what now?
Well, if there is an interest in native windows support, I would be
happy to work with someone to port various components. Otherwise, the
work is as good as abandoned. No hard feelings.
The code changes will not break the build, the code is just more
general. So its actually safe to merge this kind of work (after some
cleanup, sure) back into the mainline. But thats up to Tom and the other
gurus.
Anyways, thats my new years gift to you all.
Happy new year!
-Josh