Thread: math.h library not working with curses.h

  1. #1
    Registered User
    Join Date
    Jun 2017
    Posts
    3

    math.h library not working with curses.h

    Hello, I work for the U.S. Department of Labor. I am trying to correct a C cursor screen used by states in forecasting their Unemployment Insurance Trust Fund. I have work on on other screens used by this application, and I am getting familiar with curses.h. However, this problem ins new to me and I can use some help. The screen I am working on has the includes:

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <curses.h>
    #include <term.h>

    I have the math.h include in there, but when I compile I get the link errors:

    Undefined first referenced
    symbol in file
    exp bsyrhd.o
    log bsyrhd.o
    pow bsyrhd.o
    fabs bsyrhd.o
    sqrt bsyrhd.o

    All of these missing items are math functions that should be found in math.h, but the linker is not finding them. I use math.h in many other files in this large application, and there is not a problem with finding these functions, so I am thinking that there is some conflict between curses.h and math.h. I am compiling with the gcc compiler, using the commands:

    #! /bin/csh
    /opt/SUNWspro/bin/cc $1.c -L/usr/ccs/lib -lcurses -o $1

    Any help with this issue is greatly appreciated.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,539
    You may need to add the math library to the build line as well.


    Jim

  3. #3
    Registered User
    Join Date
    Jun 2017
    Posts
    3
    Thank you for the suggestion. I changed the compile call to :

    #! /bin/csh
    /opt/SUNWspro/bin/cc $1.c -L/usr/ccs/lib -lmath -lcurses -o $1

    Unfortunately, I get the same errors. Should the include in the command line be something other than -lmath?

  4. #4
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    726
    Try "-lm" instead of "-lmath".

  5. #5
    Registered User
    Join Date
    Jun 2017
    Posts
    3
    Thank you, jimblumberg and rstanley, adding the -lm option to the command line solved the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Math Minimization library and methods (in C++)?
    By Aragornthe5th in forum C++ Programming
    Replies: 3
    Last Post: 06-26-2010, 08:28 PM
  2. Judge my vector math library
    By DavidP in forum C# Programming
    Replies: 5
    Last Post: 07-25-2008, 07:41 PM
  3. curses library for c++?
    By e1000sn in forum C++ Programming
    Replies: 4
    Last Post: 03-09-2008, 03:13 AM
  4. Library for math strings
    By Boomba in forum C Programming
    Replies: 4
    Last Post: 10-15-2005, 08:05 PM
  5. math library
    By Eber Kain in forum C++ Programming
    Replies: 3
    Last Post: 06-16-2004, 01:11 AM

Tags for this Thread