Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Is libm.so always linked by default?

$
0
0

Hi, guys!

$ cat test.cpp

int main() {

   return 0;

}

$ icpc test.cpp -o test.exe

$ lddtree test.exe

test.exe => ./test.exe (interpreter => /lib64/ld-linux-x86-64.so.2)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2

test.cpp doesn't use any math, but libm.so still participates in the linking. Why?

By the way, when test.cpp is built with g++, then there's no dependency on the libm library.

What is the standard way to remove this redundant dependency?

I would also like to know why this dependency isn't being dropped during the linking stage by the linker itself?

 

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles