This question is highly related to cannot find -lm, but the error appears when I'm invoking cross G++ Linker.

I'm trying to follow through the documentation provided by Using Eclipse with ARTIK SDK. While following through the part 'Creating SDK project - Linux', I've encountered the following error:

18:02:24 **** Incremental Build of configuration Default for project gpio-test ****
make all 
Building target: gpio-test
Invoking: Cross G++ Linker
arm-linux-gnueabihf-g++ -L"/opt/sysroots/artik-sysroot/usr/lib" --sysroot=/opt/sysroots/artik-sysroot -o "gpio-test"  ./artik_gpio_test.o   -lartik-sdk-base
/opt/toolchains/gcc-linaro-5.4.1-2017.01-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
collect2: error: ld returned 1 exit status
make: *** [gpio-test] Error 1

18:02:24 Build Finished (took 63ms)

There is a problem invoking cross G++ linker. If I transmit the code to ARTIK, then I get the following error:

Last login: Thu Apr 13 21:10:38 2017 from


[root@artik ~]# /root/gpio-test/artik_gpio_test.c;exit
/root/gpio-test/artik_gpio_test.c: line 10: enum: command not found
/root/gpio-test/artik_gpio_test.c: line 11: R: command not found
/root/gpio-test/artik_gpio_test.c: line 12: G: command not found
/root/gpio-test/artik_gpio_test.c: line 13: B: command not found
/root/gpio-test/artik_gpio_test.c: line 14: syntax error near unexpected token `}'
/root/gpio-test/artik_gpio_test.c: line 14: `};'

What can I do?

EDIT: enter image description here

  • 4
    (1) Do you really get the /bin/ld: cannot find -lm error message at the end of a 160-character long line?  (2) Why do you say “Build seems to be successful” when the penultimate line of output says “Error 1”?  (3) Don’t try to run your source file as a command. You can run scripts, and binary executables that are generated by compilers, but not source files. – G-Man Says 'Reinstate Monica' Apr 14 '17 at 2:38
  • @G-Man Thanks for your comment! As for your question: 1) See the picture attached for verification. Does that indicate some sort of problem? 2) Sorry it was my misunderstanding. I realize that build is not successful. I've edited the question accordingly. 3) I'm using remote application in Eclipse to upload executable file in artik to run it in artik environment. But since I cannot do this now, I'm uploading the c file in artik and compiling it does not give me any error. – Hosea Apr 16 '17 at 17:22
  • I'm trying to use Eclipse to debug, but because of the error, I cannot debug the code right now. – Hosea Apr 16 '17 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.