Search code examples
c++compiler-errorsg++redhatstatic-linking

Compile C++ project statically on redhat


I'm trying to compile statically my C++ project on Redhat 7.3.

This is my script:

g++ -static -ldl -std=c++0x -O3 -fopenmp *.cpp -o main

But I obtain this error: /usr/bin/ld: cannot find -ldl

How can I fix it? I think a library misses.


Solution

  • -ldl means /usr/lib/libdl.so ( Provided by glibc-devel )

    the -static -ldl means /usr/lib/libdl.a ( Provided by glibc-static )

    yum install glibc-devel glibc-static