Like Tree1Likes
  • 1 Post By laserlight

incompatible implicit declaration of built-in function

This is a discussion on incompatible implicit declaration of built-in function within the C Programming forums, part of the General Programming Boards category; warning: incompatible implicit declaration of built-in function ‚strlen‚ warning: undefined reference to `sqrt' warning: implicit declaration of function ‚strcmp‚ warning: ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    41

    incompatible implicit declaration of built-in function

    warning: incompatible implicit declaration of built-in function ‚strlen‚
    warning: undefined reference to `sqrt'
    warning: implicit declaration of function ‚strcmp‚
    warning: implicit declaration of function ‚strcat‚
    warning: incompatible implicit declaration of built-in function ‚strcat‚

    I have all the necessary includes, do i need to do some extra command to get this to compile properly?

    How do i fix that when my SSH Secure Shell compiles the file, i get a bunch of those..

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Quote Originally Posted by Oonej
    I have all the necessary includes
    I'll believe it when I see it.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Well you would need to post your code to back up your assertion that you're including all the right files.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    41
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <math.h>

    can't post code, as this is a class project and students in my class view them... not looking to get a F for "cheating" lol

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    41
    btw - this compiles fine and works 100% in my DevC++ IDE, but doesn't compile on the SSH server, do i need to amend the header files in the compile on the SSH or something?

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    You're missing <string.h> for strlen, strcmp and strcat.

    Also, to solve "undefined reference to `sqrt'" you may need to explicitly link to the math library, e.g., with -lm
    Salem likes this.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    41
    too many arguments for format /tmp/cc3hMW6h.o: In function [function name]

    what does that refer to?

    and also how do i amend the math.h file with -lm? never used it before

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Quote Originally Posted by Oonej
    too many arguments for format /tmp/cc3hMW6h.o: In function [function name]

    what does that refer to?
    My guess is that you used too many arguments for format

    Perhaps this has something to do with printf. Or maybe with a function call. I'm not sure because you provided so little information that only someone who has come across that error message before and remembers the context and solution is likely to be able to accurately tell you the problem and solution.

    Quote Originally Posted by Oonej
    and also how do i amend the math.h file with -lm? never used it before
    What compiler are you using? Are you compiling on the command line, or from an IDE?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Jun 2011
    Posts
    41
    SSH Secure Shell - command line

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    Quote Originally Posted by Oonej
    SSH Secure Shell - command line
    SSH Secure Shell is not a compiler

    Let's suppose you are using gcc. Currently, you might be running:
    Code:
    gcc -o program source.c
    If my guess is correct, it may become:
    Code:
    gcc -o program -lm source.c
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Never modify header files like math.h present on the system.
    Besides -lm is a linker directive specified on the command line.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2010, 07:42 AM
  2. Implicit Declaration Of Function
    By nathanpc in forum C Programming
    Replies: 1
    Last Post: 01-26-2010, 07:46 PM
  3. incompatible implicit declaration of built-in function Ďexití
    By jas_atwal in forum Linux Programming
    Replies: 2
    Last Post: 11-08-2007, 01:33 AM
  4. implicit declaration of function?
    By BoneXXX in forum C Programming
    Replies: 2
    Last Post: 04-27-2007, 11:04 PM
  5. Implicit declaration of function
    By soothsayer in forum C Programming
    Replies: 5
    Last Post: 02-28-2006, 01:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21