3

I write a new "sqrt(double)" in libtest.cpp, and compile it to a dynamic (or static) library libtest.so. The function interface is same as in math.h.

Then I want to link main.o with libtest.so instead of libm.a. I am wondering how to do it with clang++ or g++.

It seems that -lstdc++ calls -lm by default.

Thanks a lot !

Feng
  • 31
  • 2
  • 2
    Given that the standard `sqrt()` is well known to compiler/library implementers, it is often inlined automatically by the compiler. Why not simply give your function a distinct name, such as `snakexf_sqrt()`, and then use that in your code? – Peter Apr 24 '17 at 13:09
  • 1
    Yes, it is a choice. However, for some reasons, it is better to use same name. – Feng Apr 24 '17 at 13:50
  • use namespace? a then `using snakexf::sqrt;` or you really want to override – jamek Apr 24 '17 at 14:25
  • with -fno-builtin and -ltest can solve it. – Feng May 03 '17 at 05:58
  • @Peter It's not necessarily our own library... it can be fdlibm or any other alternative and that means modifying sources that we do not control/master. – aka.nice Dec 08 '18 at 12:46

0 Answers0