How to Install Libraries Without a Config File

Abstract: Install C or C++ libraries from source code on Linux by compiling with GCC and CMake when no pre-built package is available.

Created: 2026-09-03 by
To install libraries without a configuration file on Linux, you must compile the source code manually using standard build tools. This process involves extracting the archive, generating the build system with CMake or configuring with Make, compiling the object files, and finally installing them to system directories. This method ensures that dependencies are resolved and binaries are placed correctly for your applications to link against.

Understanding the Build Process

When a library does not provide a pre-compiled package or a simple configuration script, you are dealing with raw source code. The goal is to transform human-readable C or C++ code into machine-executable shared objects (.so) or static archives (.a). This transformation requires a compiler like GCC or Clang and a build system to manage the complexity of multiple source files. Most modern open-source libraries use CMake because it handles cross-platform compatibility and dependency detection automatically. Older projects might still rely on GNU Autotools or plain Makefiles. Understanding this distinction is crucial because the commands you run will differ based on the project's structure. You do not need a "config file" in the sense of a GUI installer; instead, you create the necessary build environment dynamically during the compilation step.

Extracting the Source Archive

The first practical step is to obtain the source code. Libraries are typically distributed as compressed tarballs, often ending in .tar.gz or .tar.xz. Before doing anything else, ensure you have the necessary development tools installed. On Debian-based systems, this includes build-essential, which provides GCC, G++, and Make. On Red Hat-based systems, you would install gcc, gcc-c++, and make. Additionally, if the library uses CMake, you must install the cmake package. Once your tools are ready, navigate to a temporary directory where you want to build the software. Extract the archive using the tar command. For example:
tar -xzf library-name-1.0.tar.gz
This command creates a new directory containing the source files. It is important to work outside of this extracted directory to keep your workspace clean. Building directly inside the source tree can clutter the original files with generated object code and make cleaning up difficult. Instead, create a separate build directory within the extracted folder or in a parallel location. This practice, known as an out-of-tree build, is a standard convention in professional software development. If you are looking to manage hidden resources or specific file attributes during extraction, you might explore related techniques for handling archives, such as those described in Get tar command to show hidden resources for files archive?.

Configuring the Build System

If the project uses CMake, the configuration phase generates the actual Makefiles or Ninja files required for compilation. Navigate into your newly created build directory. Run the CMake command pointing to the parent directory where the CMakeLists.txt file resides. A common pattern is:
cd library-name-1.0/build
cmake ..
CMake will scan your system for required dependencies, check for compiler capabilities, and configure paths. If the library has optional features, you can enable or disable them using flags like -DENABLE_FEATURE=ON. The output will tell you if any critical dependencies are missing. If you encounter errors here, they usually indicate that you need to install additional development headers (often found in packages named -dev or -devel). For projects using traditional Makefiles, you might need to run a ./configure script first. This script performs similar checks to CMake but writes a Makefile tailored to your specific environment. After running the configuration step successfully, you should see a summary indicating that the build environment is ready.

Compiling and Installing

With the build system configured, the next step is compilation. Use the make command. To speed up the process, you can use the -j flag followed by the number of CPU cores available on your machine. For instance, make -j4 will use four jobs simultaneously. This significantly reduces build time on multi-core processors. The compiler will process each source file and link them together. If there are no syntax errors or missing dependencies, this stage completes successfully. Finally, you install the compiled library. This step requires root privileges because it writes to system directories like /usr/local/lib. Run:
sudo make install
This command copies the shared libraries, header files, and sometimes documentation to their respective locations. After installation, you may need to update the dynamic linker cache so that the system recognizes the new libraries. Run sudo ldconfig to refresh the cache. This ensures that when you link your own programs against this library, the linker can find it without needing explicit path specifications.

Verifying the Installation

To confirm that the library was installed correctly, you can check the contents of the library directory. Look for the expected .so files in /usr/local/lib or /usr/lib. You can also verify that the headers are present in /usr/local/include. If you plan to use this library in a new project, ensure that your build system knows where to look. For CMake projects, you can use find_package() if the library provides a config file. Otherwise, you may need to specify the include and library paths manually in your own CMakeLists.txt or Makefile.

Frequently Asked Questions

What if I don't have sudo access?

You can install the library to a local directory by specifying a prefix during the CMake configuration step. Use the flag -DCMAKE_INSTALL_PREFIX=$HOME/local. This allows you to manage the library entirely within your user space without requiring root privileges.

How do I uninstall a manually compiled library?

If you still have the build directory, you can run sudo make uninstall. This reverses the installation process by removing the files that were copied to system directories. If the build directory is gone, you may need to manually delete the files from /usr/local/lib and /usr/local/include.

Why did the build fail due to missing dependencies?

Most errors during the configuration or compilation phase are caused by missing development headers. Check the error message for the name of the missing library and search for its corresponding -dev or -devel package in your distribution's repository. Installing these headers usually resolves the issue.

Can I use this method for proprietary libraries?

Yes, provided you have the source code. However, proprietary libraries often come with pre-compiled binaries or specific installers. If you only have the source, the manual build process described here applies equally to open and closed-source projects.

What is the difference between static and shared libraries?

Shared libraries (.so) are loaded at runtime and allow multiple programs to share the same code in memory, reducing disk usage. Static libraries (.a) are linked directly into the executable at compile time, resulting in larger binaries but fewer runtime dependencies. You can control which type is built by changing CMake options or Make variables.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More