Atlas - BUILD.md
Home / ext / SDL / src / hidapi Rendered HTML view | Size: 5284 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]Building HIDAPI from Source
Table of content
- Intro
- Prerequisites
- Embedding HIDAPI directly into your source tree
- Building the manual way on Unix platforms
- Building on Windows
Intro
For various reasons, you may need to build HIDAPI on your own.
It can be done in several different ways: - using CMake; - using Autotools (deprecated); - using manual makefiles; - using
Meson(requires CMake);Autotools build system is historically the first mature build system for HIDAPI. The most common usage of it is in its separate README: BUILD.autotools.md.
NOTE: for all intentions and purposes the Autotools build scripts for HIDAPI are deprecated and going to be obsolete in the future. HIDAPI Team recommends using CMake build for HIDAPI.CMake build system is de facto an industry standard for many open-source and proprietary projects and solutions. HIDAPI is one of the projects which use the power of CMake to its advantage. More documentation is available in its separate README: BUILD.cmake.md.
Meson build system for HIDAPI is designed as a wrapper over CMake build script. It is present for the convenience of Meson users who need to use HIDAPI and need to be sure HIDAPI is built in accordance with officially supported build scripts.
In the Meson script of your project you need ahidapi = subproject('hidapi')subproject, andhidapi.get_variable('hidapi_dep')as your dependency. There are also backend/platform-specific dependencies available:hidapi_winapi,hidapi_darwin,hidapi_hidraw,hidapi_libusb.If you don't know where to start to build HIDAPI, we recommend starting with CMake build.
Prerequisites:
Regardless of what build system you choose to use, there are specific dependencies for each platform/backend.
Linux:
Depending on which backend you're going to build, you'll need to install additional development packages. For
linux/hidrawbackend, you need a development package forlibudev. Forlibusbbackend, naturally, you needlibusbdevelopment package.On Debian/Ubuntu systems these can be installed by running: ```sh
required only by hidraw backend
sudo apt install libudev-dev
required only by libusb backend
sudo apt install libusb-1.0-0-dev ```
FreeBSD:
On FreeBSD, you will need to install libiconv. This is done by running the following:
sh pkg_add -r libiconvMac:
Make sure you have XCode installed and its Command Line Tools.
Windows:
You just need a compiler. You may use Visual Studio or Cygwin/MinGW, depending on which environment is best for your needs.
Embedding HIDAPI directly into your source tree
Instead of using one of the provided standalone build systems, you may want to integrate HIDAPI directly into your source tree.
If your project uses CMake as a build system, it is safe to add HIDAPI as a subdirectory.
If the only option that works for you is adding HIDAPI sources directly to your project's build system, then you need: - include a single source file into your project's build system, depending on your platform and the backend you want to use: -
windows\hid.c; -linux/hid.c; -libusb/hid.c; -mac/hid.c; - add ahidapifolder to the include path when buildinghid.c; - make the platform/backend specific dependencies available during the compilation/linking, when buildinghid.c;NOTE: the above doesn't guarantee that having a copy of
<backend>/hid.candhidapi/hidapi.his enough to build HIDAPI. The only guarantee that<backend>/hid.cincludes all necessary sources to compile it as a single file.Check the manual makefiles for a simple example/reference of what are the dependencies of each specific backend.
Building the manual way on Unix platforms
Manual Makefiles are provided mostly to give the user an idea what it takes to build a program which embeds HIDAPI directly inside of it. These should really be used as examples only. If you want to build a system-wide shared library, use one of the build systems mentioned above.
To build HIDAPI using the manual Makefiles, change the directory of your platform and run make. For example, on Linux run:
sh cd linux/ make -f Makefile-manualBuilding on Windows
To build the HIDAPI DLL on Windows using Visual Studio, build the
.slnfile in thewindows/directory.To build HIDAPI using MinGW or Cygwin using Autotools, use general Autotools instruction.
Any windows builds (MSVC or MinGW/Cygwin) are also supported by CMake.
If you are looking for information regarding DDK build of HIDAPI: - the build has been broken for a while and now the support files are obsolete.
[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.