Thread: a Compiling error?

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    a Compiling error?

    Hi I'm using another programs makefile and its hard to really understand them for this C program. but basically when i compile the im using a command in the makefile
    Code:
    /sd/cc/libraries/bin/libogg.a -lm -lgcc -static
    /usr/bin/ld cannot find -lm
    collect2:ld returned 1 exit status
    Where is lm suppose to be im assuming its linking to a math library but apparently it can't find it

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,534
    Your snippet of log file doesn't make a lot of sense.

    it looks like you're trying to run libogg.a (for example).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    my bad but basically im looking for a path to find the -lm to work and reading online basically it needs to do with libm.so and libm.a which is in my /usr/lib/ directory so should i just link a path that way to make gcc accept -lm

  4. #4
    Trying to Learn C nathanpc's Avatar
    Join Date
    Jul 2009
    Location
    Brazil
    Posts
    72
    Could you please inform more, because we can't know what you need without more information.

    Edit
    This is what you're looking for?
    Last edited by nathanpc; 05-21-2010 at 11:41 AM.
    Follow Me At Twitter
    Eee PC 904HD White | Windows XP Home Edition and Linux Ubuntu Hardy Herron

    Google Talk: eeepc904@gmail.com
    ICQ: 424738586
    AIM: nathanjava

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by kiros88 View Post
    my bad but basically im looking for a path to find the -lm to work and reading online basically it needs to do with libm.so and libm.a which is in my /usr/lib/ directory so should i just link a path that way to make gcc accept -lm
    If you want gcc to use the math libraries, -lm is the way to go, but you need to have gcc involved:
    Code:
    gcc -o prog source_code.c -lm
    It's not a separate command.

  6. #6
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    oaky so i just have a question im reading the compiler line and its almost looks like its at teh very end the -lm but right after it is
    Code:
    .......    -lm -lgcc -static  /.../.../.../.../somthing.o
    So i do have a cc -o prog source_code.c before the -lm but this stuff is after it would it matter? the object file is compiled in another directory so that exist

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Those are other libraries/object files that you are also linking with. (Well, not static, that's just a compiler switch.)

  8. #8
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    But so basically my -lm is in the right place right? cuz I'm still getting the same compiling error and im not sure if I'm just suppose to move the -lm behind the random object file?

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What error message are you getting, and show the whole line.

  10. #10
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    Code:
    root@vmfedora wadst]# make
    cc --prefix=/sd/cns3xxx-bsp/tools/cnstools/arm-linux-2.6-mpcore-uclibc-le-2009.05/usr -g -ggdb -O0 -Wall  -I ../../include -I ../../apps/adad -I ../../flac-1.1.3/include -I ../../flac-1.1.3/include/FLAC -I ../../libraries/libtrans -DCPUARCH_ARM  -DCONFIG_CPU_BIG_ENDIAN -o wadst wadst.o -g /sd/cc/libraries/bin/libtrans.a -g /sd/cc/libraries/bin/libFLAC.a -g /sd/cc/libraries/bin/libogg.a -lm -lgcc   -static 	/sd/cc/apps/adad/dacapi.o
    /usr/bin/ld: cannot find -lm
    collect2: ld returned 1 exit status
    make: *** [wadst] Error 1
    I mean the line is pretty long and im pretty sure the position of everything is correct but I just found out that im missing the libm.a in the /usr/lib directory but i have libm.so so does that just mean i need to just have a libm.a installed or something

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you use the --static flag, then no linking with dynamic/shared libraries is going to happen, that is correct. You may need to find or re-create libm.a in that case.

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,534
    It seems you're using an ARM cross-compiler.

    What other libraries are in /sd/cc/libraries/bin/ ?

    You tell the linker where to look for libraries using -L

    So if you happen to find /sd/cc/libraries/lib/libm.a
    Then you would add
    -L/sd/cc/libraries/lib
    to the compiler command line.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    Okay sorry for all this hassle it helped me though think about it i realized the error was stupid I checked the fedora software and all i had to do was download a glibc static libraries and that fixed everything thank you all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM