Thread: decimal to number if digits in different bases

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by jorgejags View Post
    that made it work. but how do i make it work without adding -lm
    Don't use log (or any other function out of math.h). [There is a suggestion above about "how to do it if you don't know much math" which would work]

    But I doubt there's much point to that. Using -lm is fine unless you have a particularly quirky tutor... [Or the particular wording to your project says "do not use the math library" or some such].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by jorgejags View Post
    it just doesnt compile. it gives me this when i try to compile it. i am using unix

    > gcc num-digits.c
    Undefined first referenced
    symbol in file
    log /var/tmp//ccNuKjnz.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status
    What about gcc num-digits.c -lm ?

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by tabstop View Post
    What about gcc num-digits.c -lm ?
    A bit slow today, are we?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by matsp View Post
    A bit slow today, are we?

    --
    Mats
    I didn't click enough "More replies below current depth...", or count (num posts - num I can see). Sorry

  5. #20
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I guess the question at hand is what is wrong with needing to compile in the math library? Mingw just does it implicitly. If you were to erase libm.a from your machine you would not be able to compile it with mingw either. Furthermore, you can explictly -lm on mingw and still compile just fine on windows (if your question is something to the effect of "how do I make a single makefile").

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And the reason that gcc-mingw is "different" here is that it's not using glibc, but rather the MS C-library (msvcrt.dll), which has both math and standard library functions in one library, so there's no need to inform gcc about the fact that you are using math functions, because it is part of the basic standard library anyways.

    That's just the way it is when working with different environments - sometimes you need to do things different from one system to another, because someone somewhere took some arbitrary decision to do things differently than some other system. It's not that one is definitely right and the other is wrong, just different.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #22
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I just want the OP to be clear on one thing. For the sake of your makefiles or whatever the -lm is simply ignored by mingw.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. Learning Memory, Ins and Outs?
    By Zoiked in forum C Programming
    Replies: 1
    Last Post: 08-27-2007, 04:43 PM
  4. Number of digits?
    By falador in forum C Programming
    Replies: 2
    Last Post: 05-13-2004, 03:52 AM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM