C Compiler Logo

Missing Library

Missing Library

linker
cannot find -lmylib

Description

The linker cannot find a library that is specified in the compilation command.

Common Causes

Example of Error

Error Code

// Compilation command
// gcc -o program main.c -lmylib

Solution

Install the missing library or specify the correct path to it.

Corrected Code

// Install the library
// sudo apt-get install libmylib-dev

// Or specify the path
// gcc -o program main.c -L/path/to/lib -lmylib

Additional Tips