Building a C/C++ Application
- Updated2025-12-04
- 2 minute(s) read
Creating a Project
Use your development tools to create a project or a makefile that includes the two header files and the source file. Add a new source file to the project or makefile. In the new source file, use #include to include the generated .h header file. The generated .h header file uses #include to include NiFpga.h.
The Examples directory contains examples of project files and makefiles for different operating systems.
If you are developing an application for an NI Linux Real-Time target, use the C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition 2013 or later. For information about the development tools, go to ni.com/info and enter the EclipseIDE info code.
If you are developing an application for an R Series device, refer to the NI tutorial Building an R Series FPGA Interface Host Application in C.
Writing C/C++ Code Using FPGA Interface C API Functions
All C/C++ applications must call the required functions. In order to interact with FPGA VIs, your application must call a session function to open an FPGA session. From there, call other functions in NiFpga.h to read and write to controls and indicators, use interrupts, or use other C/C++ functions.
Refer to the installed examples to see how to use C API functions.
Developing and Maintaining the C/C++ Application
The constants in the generated header file are tied to the specific bitfile used to generate them. If you modify the FPGA VI, you must recompile the VI, regenerate the C API, and rebuild any C/C++ application that used the original C API. This is because the register offsets for controls and indicators may have changed unexpectedly. If you do not regenerate and rebuild, and instead try to use a new bitfile with an older application, you get the NiFpga_Status_SignatureMismatch error message. The signature of the bitfile does not match the signature passed to the NiFpga_Open function.