1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
/*! \page page_build_guide Building and Installing UHD from source
\tableofcontents
\section build_dependencies Build Dependencies
<b>Linux Notes:</b>
This is dependent on the distribution you are using, but most, if not all, of
the dependencies should be available in the package repositories for your
package manager.
<b>Mac OS X Notes:</b>
Install the Xcode app to get the build tools (GCC and Make).
Use MacPorts to get the Boost and Mako dependencies.
Other dependencies can be downloaded as DMG installers from the web
or installed via MacPorts.
See the UHD OS X build instructions for more information: \ref build_instructions_osx
<b>Windows Notes:</b>
The dependencies can be acquired through installable EXE files.
Usually, the Windows installer can be found on the project's website.
Some projects do not host Windows installers, and if this is the case,
follow the auxiliary download URL for the Windows installer (below).
### C++ Compiler
The following compilers are known to work and officially supported:
- GCC >= 4.8
- Clang >= 3.3
- MSVC >= 2015 (14.0); the free version works.
Other compilers (or lower versions) may work, but are unsupported.
### CMake
- **Purpose:** generates project build files
- **Minimum Version:** 2.8
- **Usage:** build time (required)
- **Download URL:** http://www.cmake.org/cmake/resources/software.html
### Boost
- **Purpose:** C++ library
- **Minimum Version:** 1.53
- **Usage:** build time + runtime (required)
- **Download URL:** http://www.boost.org/users/download/
- **Download URL (Windows installer):** http://sourceforge.net/projects/boost/files/boost-binaries/
### LibUSB
- **Purpose:** USB-based hardware support
- **Minimum Version:** 1.0
- **Usage:** build time + runtime (optional)
- **Download URL:** http://sourceforge.net/projects/libusb/files/libusb-1.0/
- **Download URL (Windows):** https://github.com/libusb/libusb
### Python
- **Purpose:** used by mako and utility scripts
- **Minimum Version:** 2.7
- **Usage:** build time + runtime utility scripts (required)
- **Download URL:** http://www.python.org/download/
### Mako
- **Purpose:** source code generation
- **Minimum Version:** 0.5.0
- **Usage:** build time (required)
- **Download URL:** http://www.makotemplates.org/download.html
- **Alternative method:** You can use `pip` or `easy_install` to install Mako from PyPi.
### Doxygen
- **Purpose:** generates HTML API documentation
- **Minimum Recommended Version:** 1.8
- **Usage:** build time (optional)
- **Download URL:** http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc
- **Alternate method:** Install **setuptools**, and use the **easy_install** command to install Docutils. http://pypi.python.org/pypi/setuptools
### Git
Required to check out the repository (not necessary if building from tarballs).
On Windows, install Cygwin with Git support to checkout the repository
or install msysGit from http://code.google.com/p/msysgit/downloads/list.
\subsection build_dependencies_ubuntu Setting up the dependencies on Ubuntu
You can install all the dependencies through the package manager:
sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-mako doxygen python-docutils cmake build-essential
Your actual command may differ.
\subsection build_dependencies_fedora Setting up the dependencies on Fedora
You can install all the dependencies through the package manager:
sudo yum -y install boost-devel libusb1-devel python-mako doxygen python-docutils cmake make gcc gcc-c++
or
sudo dnf -y install boost-devel libusb1-devel python-mako doxygen python-docutils cmake make gcc gcc-c++
Your actual command may differ.
\section build_get_source Getting the source code
The UHD source is stored in a Git repository. To download it, follow these instructions:
git clone git://github.com/EttusResearch/uhd.git
If you also want the FPGA code (which is not necessary for building UHD and applications which depend on it), run:
git clone --recursive git://github.com/EttusResearch/uhd.git
This will populate the `fpga-src` submodule inside the repository. You can also do this after cloning the repository by running these commands from the top level source directory:
git submodule init
git submodule update
Our source code repository contains of two main branches:
\li \b master: This is the main development branch, with updated new features and bug fixes.
\li \b maint: This branch has all bugfixes since the last major release, but there are no new features. This is what you should be using if you need a stable release.
We might also be publishing experimental feature branches which can then be found in the same repository.
All of our versioned releases are associated with tags in the repository.
\li <a href="https://github.com/EttusResearch/UHD/tags">Source archives for release tags</a>
\section build_pybombs Using PyBOMBS
PyBOMBS is a command-line tool for Linuxes (and some Unixes) from the GNU Radio ecosystem and will do a source build of UHD, including setting up prerequisites/dependencies (regardless of the distribution). Assuming you have PyBOMBS set up, you can install UHD with the following command:
$ pybombs install uhd
Head to the <a href="https://github.com/gnuradio/pybombs/#installation">PyBOMBS Homepage</a> for more instructions. PyBOMBS can install UHD (as well as GNU Radio or similar projects) both into system directories as well as into user's home directories, omitting the requirement for superuser access.
\section build_instructions_unix Build Instructions (Unix)
\subsection generate_unix Generate Makefiles with CMake
cd <uhd-repo-path>/host
mkdir build
cd build
cmake ../
Additionally, configuration variables can be passed into CMake via the command line.
The following common-use configuration variables are listed below:
- For a custom install prefix: `-DCMAKE_INSTALL_PREFIX=<install-path>`
- To install libs into lib64: `cmake -DLIB_SUFFIX=64`
Example usage:
cmake -DCMAKE_INSTALL_PREFIX=/opt/uhd ../
\subsection build_install_unix Build and install
make
make test
sudo make install
\subsection libpath_linux Setup the library path (Linux)
Make sure that `libuhd.so` is in your `LD_LIBRARY_PATH`,
or add it to `/etc/ld.so.conf` and make sure to run:
sudo ldconfig
\section build_instructions_windows Build Instructions (Windows)
\subsection cmake_win Generate the project with CMake
- Open the CMake GUI.
- Set the path to the source code: `<uhd-repo-path>/host`.
- Set the path to the build directory: `<uhd-repo-path>/host/build`.
- Make sure that the paths do not contain spaces.
- Click "Configure" and select "Microsoft Visual Studio 10".
- Set the build variables
- `Boost_INCLUDE_DIR` should point to the `PATH` where the Boost .hpp files are, e.g. `C:\local\boost_version\boost`
- `Boost_LIBRARY_DIR` should point to the pre-built libraries, e.g. `C:\local\boost_version\lib64-msvc-14.0`)
.
- Click "Generate", and a project file will be created in the build directory.
\subsection msvc_generate Compile and Install with Visual Studio
- Open the `<uhd-repo-path>\\host\\build\\ALL_BUILD.vcxproj` in visual studio, generate the project. Watch the output console for errors.
- If you did not specify a `CMAKE_INSTALL_PREFIX` where your user has write privileges, you must close Visual Studio, run it again with Administrator Privileges, and open `ALL_BUILD.vcxproj`.
- Right click on the **INSTALL** project in the project explorer, generate it. Watch the output console for errors.
\subsection libusb_notes LibUSB notes
On Windows, CMake does not have the advantage of `pkg-config`,
so we must manually tell CMake how to locate the LibUSB header and lib.
- From the CMake GUI, select "Advanced View".
- Set `LIBUSB_INCLUDE_DIRS` to the directory with `libusb.h`.
- Set `LIBUSB_LIBRARIES` to the full path for `libusb-1.0.lib`.
- Recommend the static `libusb-1.0.lib` to simplify runtime dependencies.
- Check the box to enable USB support, click "Configure" and "Generate".
<b>Note:</b> On Windows, LibUSB v1.0.19 is required to use most USB3 controllers.
\subsection build_in_msvc Build the project in MSVC
- Open the generated project file in MSVC.
- Change the build type from "Debug" to "Release".
- Select the "Build All" target, right-click, and choose "Build".
- Select the install target, right-click, and choose "Build".
<b>Note:</b>
You may not have permission to build the install target.
You need to be an administrator or to run MSVC as administrator.
\subsection build_msvc_cmd_line Build the project in MSVC (command line)
Open the Visual Studio Command Prompt Shorcut:
cd <uhd-repo-path>\host\build
DevEnv uhd.sln /build Release /project ALL_BUILD
DevEnv uhd.sln /build Release /project INSTALL
\subsection path_env Setup the PATH environment variable
* Add the UHD bin path to `%PATH%` (usually `C:\\Program Files\\UHD\\bin`)
<b>Note:</b>
The default interface for editing environment variable paths in Windows is very poor.
We recommend using "Rapid Environment Editor" (http://www.rapidee.com) over the default editor.
\section build_instructions_osx Build Instructions (Mac OS X)
### X11/XQuartz or Terminal
For the purposes of building and using UHD, you can use Apple's Terminal.app if you so choose, no matter how you install UHD.
That said, running almost any graphical interface (GUI) will require downloading and installing X11/XQuartz first. Through OSX 10.8, Apple provided a means to install X11.app, but XQuartz has always been more up to date. Staring in 10.9, Apple no longer provides a full working version of X11.app. Hence, just use XQuartz from the get-go. Note that unless you experiment with using the Quartz interface to various graphical toolkits (e.g., GTK), you must use X11 as the terminal interface for any GUI applications.
### Xcode
Apple provides a fully integrated development environment via their Xcode toolkit, which can be downloaded either via the App store or directly from Apple's Developer area depending on the version of OSX in use. Xcode provides the compilers and related development tools needed to build or execute UHD and its dependencies.
Once Xcode is installed, you must still install the Command Line Tools, which can be accomplished by running Xcode.app, then going to Preferences... -> Downloads and making sure Command Line Tools is selected/enabled [feel free to select other downloads too]. You might be able to install the Command Line Tools in a terminal using
xcode-select --install
but this command will not work with every OSX / Xcode combination (e.g., does not work with OSX 10.8 and Xcode 5, but does work with OSX 10.9 and Xcode 5).
Once the Command Line Tools are installed, UHD and other projects can be installed either from source or, preferably, via MacPorts.
### Background Dependencies
There are a number of background libraries and applications that must be installed from source or binary in order to compile or execute UHD; for a full list, see \ref build_dependencies. These can be obtained by using <a href="http://www.macports.org/">MacPorts</a>, <a href="http://fink.sourceforge.net/">Fink</a>, <a href="http://brew.sh/">HomeBrew</a>, and/or from source / scratch. MacPorts tends to be more up-to-date with respect to new releases, which can be both a blessing and a curse since sometimes new released are untested and result in build or runtime errors. MacPorts, HomeBrew, and Fink offer thousands of ready-to-install libraries and applications, and hence they are highly recommended to use instead of installing from source / scratch.
Many UHD developers first install UHD using MacPorts in order to get all of the necessary background dependencies installed, then remove just UHD via
sudo port install uhd
sudo port uninstall uhd
\b NOTE: We highly recommended that all dependencies be installed via the same package manager! When issues arise, they are much easier to track down, and updating to newer versions of UHD as well as dependencies is much easier.
\b NOTE: Other package managers (e.g., Fink, HomeBrew) will require different commands than the above to install all dependencies and then remove the UHD install. Please consult the specific package manager in use for how to do these commands properly; they will not be covered here.
#### Compiling UHD from Source
Installing UHD from source follows the standard cmake method as found in many places, with a few arguments to make sure cmake always finds the correct version of Python, and uses the desired compiler. First, download the source code either via a release or via GIT.
For example, on OSX 10.8+ and using Xcode's legacy Apple GCC (via llvm), MacPorts installed into /opt/local (the default), and for Python 2.7 as installed by MacPorts, issue the following commands from within the UHD source directory:
$ mkdir build
$ cd build
$ CC=/usr/bin/llvm-gcc CXX=/usr/bin/llvm-g++ cmake -DCMAKE_INSTALL_PREFIX=/opt/local -DPYTHON_EXECUTABLE=/opt/local/bin/python2.7 -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Headers -DPYTHON_LIBRARY=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python ../host
$ make
If make succeeds, then you can test the build for errors via
$ make test
To install the build, issue
$ sudo make install
Selecting another compiler is as simple as changing the CC and CXX pre-arguments to the cmake command. Similarly, one can change the install prefix by changing the setting of the variable CMAKE_INSTALL_PREFIX.
\b NOTE: All of the PYTHON defines must point to the same install of Python, otherwise runtime errors are likely to occur.
\b NOTE: When using some other package manager (e.g., Fink, HomeBrew), the actual variable settings (-D...=...) will be different than those above. Please consult the specific package manager in use for how to do these settings properly; they will not be covered here.
\section post_install_tasks Post-Install Tasks
- After installing, you might want to download the FPGA images packages by running
`uhd_images_downloader` on the command line, or one of these executables (the actual path may differ based on your installation):
+ Linux: /usr/local/lib/uhd/utils/uhd_images_downloader.py
+ Windows: C:\\Program Files\\share\\uhd\\utils\\uhd_images_downloader.py
+ Mac OS X: In MacPorts, when UHD is installed the images are automatically downloaded and installed into their proper location. For any other package manager or install method, you should execute the uhd_images_downloader.py script to get the images installed appropriately.
- For USB-Based devices, make sure to read \ref transport_usb for platform-specific post-installation tasks.
\section build_apps Building applications that require UHD using CMake
If your application uses CMake as a build system, the following command
will setup up your build environment to link against UHD:
\code{.cmake}
find_package(UHD "3.10.0")
\endcode
This will set the CMake variable `UHD_INCLUDE_DIRS` and `UHD_LIBRARIES`
accordingly.
See the example in `examples/init_usrp` for more details, as well as
the UHDConfig.cmake file that gets installed along with the UHD libraries.
\section build_static Static Builds
Using CMake, UHD can be built as a static library by switching on
`ENABLE_STATIC_LIBS`.
cmake -DENABLE_STATIC_LIBS=ON <path to UHD source>
When linking the static library, you must ensure that the library
is loaded in its entirety, otherwise global objects aren't initialized
at load-time and it will always fail to detect any devices.
Also, \b all UHD dependencies for UHD must be provided unless your
linker has other ways of resolving library dependencies.
With the GNU ld linker (e.g. on Linux platforms), this is done using
the `--whole-archive` switch. Using the GNU C++ compiler, the correct
command line is:
g++ your_uhd_app.cpp -Wl,-whole-archive <path to UHD libs>/libuhd.a -Wl,-no-whole-archive -ldl -lpthread -l<all other libraries>
Note that `--whole-archive` is disabled after including `libuhd.a`.
The exact list of libraries depends on your UHD build. When using `UHDConfig.cmake`
(see \ref build_apps), the path to `libuhd.a` is saved into `UHD_LIBRARIES`,
and `UHD_STATIC_LIB_DEPS` lists the required dependencies. See `UHDConfig.cmake`
for details.
*/
// vim:ft=doxygen:
|