In order to use a library in C, you need to tell the compiler where the header files are, and tell the linker where to find the needed libraries. The issue is that your program will not compile on another computer if the header and the libraries are elsewhere.
Select the directory containing the program where you want to add the library in the project view, click on the right mouse button to make the project context menu appear and select Properties.
Or from the main menu, select Project ▸ Properties. By default, it edits the properties of the currently selected item in the project view. You can select a different node, by expanding Browse other nodes and selecting another one.
If the header files are installed in a standard location (/usr/include) you don't have to set this. If not, you need to add -Iinclude_path in the C preprocessor flags property if you are using gcc as your compiler. You can add several paths separated with spaces. These options will be used for all targets inside this directory.
You might have to expand the More options button to see this. Click on the Apply button when you are done.
Next, you need to add the library to a target. Select the target where you want to add the library in the project view, click on the right mouse button to make the project context menu appear and select Properties.
Or from the main menu, select Project ▸ Properties. By default, it edits the properties of the currently selected item in the project view. You can select a different node, by expanding Browse other nodes and selecting another one.
You need to set the Linker flags property, adding -llibrary_name if your compiler is gcc. library_name is the name of the library file without the lib prefix and without the .a or .so extension.
If the library is in not in a standard directory, gcc can look in additional directories with the option -Llibrary_path.
Select the target that has the library you want to remove in the project view, click on the right mouse button to make the project context menu appear and select Properties.
Remove the library from the C preprocessor flags and Linker flags properties. Click on the Apply button to write the changes to the project files.
Got a comment? Spotted an error? Found the instructions unclear? Send feedback about this page.