Undefined reference to 'pow' even though -lm is a compile flag. [C]

前端 未结 2 966
不思量自难忘°
不思量自难忘° 2020-12-10 16:36

Any reason

cc -g -lm -DBLITZ_HOST_IS_LITTLE_ENDIAN

would produce an error with code using math.h? Is it possible there\'s a d

2条回答
  •  醉酒成梦
    2020-12-10 17:13

    I've recently suffer this problem using an automatic builder, namely drone.io.

    The problem was that gcc in Ubuntu 12.04 was linking by default with -Wl,--as-needed. In my case, the project was using autotools, which means I was too lazy to write anything to modify the compilation order. Instead, modifying as-needed flag fixed the problem.

    -gabriel_LDFLAGS = $(GLIB2_LIBS) $(DBUS_LIBS) -lssh
    +gabriel_LDFLAGS = -Wl,--no-as-needed $(GLIB2_LIBS) $(DBUS_LIBS) -lssh
    

    For full info, you can check the fixing commit in https://bitbucket.org/kikeenrique/gabriel/commits/f08eefdca3f7bb90f48f5a6fbfc8839422572508

    You can take a look to the log with errors BEFORE applying the fix and also you can take a look to the log without errors AFTER applying the fix.

提交回复
热议问题