error adding symbols: dso missing from command line
The error message:
error adding symbols: dso missing from command line
typically happens when you’re compiling a program (usually C or C++) using gcc
or g++
, and the linker (ld
) can’t find a required shared object (DSO) or dynamic library.
What it means:
It usually points to the fact that you used a function or symbol from a library, but you didn’t explicitly tell the linker to include that library.
Common Causes & Fixes:
1. Missing -l
flag during linking
If you’re using a library like pthread
, m
, dl
, or others, you need to explicitly tell the compiler during linking.
For example:
- If you’re using
pthread_create
→ Add-lpthread
- If you’re using
sqrt
orsin
from math → Add-lm
- If you’re using
dlopen
→ Add-ldl
Example:
gcc main.c -o main -lpthread
2. Wrong order of linking arguments
In gcc
, libraries must come after the source or object files that use them.
Wrong:
gcc -lpthread main.c -o main
Correct:
gcc main.c -o main -lpthread
3. You’re using C++ standard libs but compiling with gcc
If you’re writing C++ code but using gcc
instead of g++
, you may need to manually link C++ standard libraries, which is usually handled by g++
.
Fix:
Use g++
instead of gcc
for linking C++ code.
If you want to share the exact compile command you’re using and any relevant source or error output, I can help you debug the specific case.