Linux Compiler/Linker Issues
- Updated2023-02-21
- 2 minute(s) read
Linux Compiler/Linker Issues
This section describes considerations for programming applications for Linux.
The LabWindows/CVI Runtime as a Shared Library
The LabWindows/CVI development environment contains many built-in libraries, such as the User Interface Library and Utility Library. LabWindows/CVI also provides these libraries in the form of a stand-alone shared library called the LabWindows/CVI Runtime. All executables that call LabWindows/CVI library functions use the Runtime shared library.
Compatible External Compilers
You can use the GNU C Compiler (gcc), an external ANSI C compiler, to compile source files for linking with the LabWindows/CVI Runtime shared library.
Main Function Must Call InitCVIRTE
If your program calls any functions from the LabWindows/CVI libraries, you must call InitCVIRTE call InitCVIRTE to initialize the libraries from the executable. This function takes three arguments. The first and third arguments to this function must always be 0 for UNIX applications. The second must be the same value as the second parameter of your main function. InitCVIRTE returns 0 if it fails.
You do not have to call InitCVIRTE when you run your program in the LabWindows/CVI development environment because LabWindows/CVI always initializes the libraries. However, if you do not call InitCVIRTE, your executable cannot work. For this reason, National Instruments recommends that you always include source code similar to the following example in your program.
int main(int argc, char *argv[])
{
if (InitCVIRTE(0, argv, 0) == 0) {
return 1;/* Failed to initialize */
}
/* your program code here */
}
If you pass NULL for the second argument to InitCVIRTE, your program might still work, but with the following limitations:
- Your executable cannot accept the -display command line argument. As a result, you cannot specify an X display on the command line for your program to use. You still can use the DISPLAY environment variable to specify a different X display.
- LoadPanel, LoadExternalModule, DisplayImageFile, SavePanelState, RecallPanelState, and other functions that normally use the directory of the executable to search for files, use the current working directory instead. If you run the executable from a directory other than the one that contains your executable, some of these functions might fail to find files.