FAQ  •  Login

Math function compile errors

<<

f13-759-rmays

Newbie
Newbie

Posts: 49

Joined: Mon Sep 09, 2013 9:12 am

Unread post Sun Nov 24, 2013 12:16 pm

Math function compile errors

Hi all,

I have a separate function called fun which takes an argument x and returns exp(sin(x))*cos(x/40). On my personal machine this compiles fine. I am including stdio.h, stdlib.h, and math.h at the top of the file.

When I attempt to compile on Euler I get errors:
  Code:
[rmays@euler01 10Homework]$ gcc Integral.cpp -o integrate.out
/tmp/ccQPSNFB.o: In function `fun(double)':
Integral.cpp:(.text+0x202): undefined reference to `sin'
Integral.cpp:(.text+0x207): undefined reference to `exp'
Integral.cpp:(.text+0x222): undefined reference to `cos'
/tmp/ccQPSNFB.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


I saw a suggestion that I should include the -lm flag at the end of my compilation line. Now I get a different error:
  Code:
[rmays@euler01 10Homework]$ gcc Integral.cpp -o integrate.out -lm
/tmp/ccW9d43K.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


Any idea what's going on?

Thanks,

-Owen
<<

f13-759-rmays

Newbie
Newbie

Posts: 49

Joined: Mon Sep 09, 2013 9:12 am

Unread post Sun Nov 24, 2013 12:21 pm

Re: Math function compile errors

I fixed the math errors by linking to stdc++:
  Code:
 gcc Integral.cpp -o integrate.out -lstdc++


Now I can't get it to find mpi.h:
  Code:
[rmays@euler01 10Homework]$ gcc Integral.cpp -o integrate.out -lstdc++
Integral.cpp:1:17: error: mpi.h: No such file or directory


:-/

-Owen
<<

f13-759-nsubramania2

Newbie
Newbie

Posts: 45

Joined: Mon Sep 09, 2013 9:12 am

Unread post Sun Nov 24, 2013 3:08 pm

Re: Math function compile errors

Owen,

I compiled it as

  Code:
gcc -fopenmp -lm code.c -o code


Hope it works.
- Naveen
<<

f13-759-rmays

Newbie
Newbie

Posts: 49

Joined: Mon Sep 09, 2013 9:12 am

Unread post Sun Nov 24, 2013 6:01 pm

Re: Math function compile errors

Thanks Naveen!

The -fopenmp flag did the trick.

-Owen
<<

xiudongwu

Newbie
Newbie

Posts: 15

Joined: Fri Sep 04, 2015 12:51 pm

Unread post Sat Dec 12, 2015 11:14 am

Re: Math function compile errors

Thanks Naveen!

Return to ME759 Fall 2013: High Performance Computing

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.