[Bug 1851341] [NEW] gcc linking fails: undefined reference to sqrt

Tim Tei 1851341 at bugs.launchpad.net
Tue Nov 5 07:56:33 UTC 2019


Public bug reported:

The code I try to compile and link:

$ cat s.c

#include <stdio.h>
#include <math.h>

int main()
{
        double n = 5.0;
        printf("%f\n", sqrt(n));
}

Linking fails with gcc, gcc-7, gcc-8, gcc-9:

$ gcc -lm s.c
/usr/bin/ld: /tmp/ccBhhS0F.o: in function `main':
s.c:(.text+0x23): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status

Linking succeeds with g++, clang:

$ g++ -lm s.c
$ clang -lm s.c

Tested with Ubuntu 18.04 and 19.10.

On Debian linking with gcc works fine.

ProblemType: Bug
DistroRelease: Ubuntu 19.10
Package: gcc 4:9.2.1-3.1ubuntu1
ProcVersionSignature: Ubuntu 5.3.0-19.20-generic 5.3.1
Uname: Linux 5.3.0-19-generic x86_64
ApportVersion: 2.20.11-0ubuntu8.2
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Tue Nov  5 08:46:14 2019
ProcEnviron:
 LANGUAGE=de_DE:
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
SourcePackage: gcc-defaults
UpgradeStatus: Upgraded to eoan on 2019-10-29 (6 days ago)

** Affects: gcc-defaults (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug eoan

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1851341

Title:
  gcc linking fails: undefined reference to sqrt

Status in gcc-defaults package in Ubuntu:
  New

Bug description:
  The code I try to compile and link:

  $ cat s.c

  #include <stdio.h>
  #include <math.h>

  int main()
  {
          double n = 5.0;
          printf("%f\n", sqrt(n));
  }

  Linking fails with gcc, gcc-7, gcc-8, gcc-9:

  $ gcc -lm s.c
  /usr/bin/ld: /tmp/ccBhhS0F.o: in function `main':
  s.c:(.text+0x23): undefined reference to `sqrt'
  collect2: error: ld returned 1 exit status

  Linking succeeds with g++, clang:

  $ g++ -lm s.c
  $ clang -lm s.c

  Tested with Ubuntu 18.04 and 19.10.

  On Debian linking with gcc works fine.

  ProblemType: Bug
  DistroRelease: Ubuntu 19.10
  Package: gcc 4:9.2.1-3.1ubuntu1
  ProcVersionSignature: Ubuntu 5.3.0-19.20-generic 5.3.1
  Uname: Linux 5.3.0-19-generic x86_64
  ApportVersion: 2.20.11-0ubuntu8.2
  Architecture: amd64
  CurrentDesktop: ubuntu:GNOME
  Date: Tue Nov  5 08:46:14 2019
  ProcEnviron:
   LANGUAGE=de_DE:
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   LANG=de_DE.UTF-8
   SHELL=/bin/bash
  SourcePackage: gcc-defaults
  UpgradeStatus: Upgraded to eoan on 2019-10-29 (6 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1851341/+subscriptions



More information about the foundations-bugs mailing list