Undefined reference to 'cos'/'sin' etc

This topic contains 2 replies, has 2 voices, and was last updated by  Shuran 1 year, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #53630

    Shuran
    Member

    Hi, all,

    I meet an issue about head file of C language in Codescape, when I included ‘#include <math.h>’ and compile my C programme, the compiler returns ‘undefined reference to cos/sin etc’, as one attachment shows.

    I modified the linkage path in environment variable, and makefile file content -Im behind the $(COBJECT) as another attachment shows. I reset the default of the Codescape app now, and the issue is still there. I attach a piece of my code snippet, I think the programme should recognize the cos()/sin()/abs() etc but it keeps throwing out errors.

    Anyone who have idea to this issue?

    Knowledge: Thanks for Sean Raby advice before.

    Attachments:
    You must be logged in to view attached files.
    1 user thanked author for this post.
    #53636

    Sean
    Moderator

    Shuran,

    Inspecting the command line, it looks like you have used -Im <india, mike>.

    2016-05-10_11-56-51

    Please try again with -lm <lima, mike>.

    See https://en.wikipedia.org/wiki/NATO_phonetic_alphabet for india, mike and lima referances.

    As discussed, this [-lm] is to force libm to be linked, in some cases it is not implicitly used at link time.

    Sean.

    Attachments:
    You must be logged in to view attached files.
    1 user thanked author for this post.
    #53640

    Shuran
    Member

    Ah… Okay, Sean.

    I modified the Makefile and re-compiled my programs again, it passes!

    Brilliant!

    Many thanks!

    Best,
    Shuran

    Attachments:
    You must be logged in to view attached files.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.