c++ - Cannot find sin(double), sin(double&), cos(double), cos(double&) -


this simple question puzzling me.

i'm getting following error(s) 1 source file not other:

4  src/source2.cpp:1466: error: no matching function call ‘cos(double&)’ 5  src/source2.cpp:1466: error: no matching function call ‘sin(double)’ 6  src/source2.cpp:1467: error: no matching function call ‘sin(double&)’ 7  src/source2.cpp:1467: error: no matching function call ‘sin(double)’ 8  src/source2.cpp:1468: error: no matching function call ‘cos(double)’ 9  src/source2.cpp:1479: error: no matching function call ‘cos(double&)’ 10 src/source2.cpp:1479: error: no matching function call ‘sin(double)’ 11 src/source2.cpp:1480: error: no matching function call ‘sin(double&)’ 12 src/source2.cpp:1480: error: no matching function call ‘sin(double)’ 13 src/source2.cpp:1481: error: no matching function call ‘cos(double)’ 

which weird since have header1.hpp/source1.cpp working, header2.hpp/source2.cpp not working. difference between them source2 using "doubles" , source1 using "floats", casting gave same errors above 'sin(float)' or 'cos(float)'.

i think i'm linking math library since other source (same program) works , doesn't complain.

any advice appreciated =)

thanks in advance!

code snippets:

header1.hpp:

4  #include <iostream> 5 6  #include <stdio.h> 7  #include <math.h> 8  #include <ctime> 9 10 #define gl_glext_prototypes 11 13 #include <opengl/gl.h> 14 #include <glut/glut.h> 

source1.cpp:

123   aim[0] = cos(camtheta)*sin(camphi); 124   aim[1] = sin(camtheta)*sin(camphi); 125   aim[2] = cos(camphi); 126  127   up[0] = cos(camtheta)*sin(camphi - pih); 128   up[1] = sin(camtheta)*sin(camphi - pih); 129   up[2] = cos(camphi - pih); 

header2.hpp:

4  #include <algorithm> 5  #include <iostream> 6  #include <fstream> 7  #include <sstream> 8  #include <vector> 9  #include <cmath> . . . 25 #define pih (m_pi/2.0) 26 #define pi m_pi 27 #define pi2 (2.0*m_pi) 

source2.cpp:

1453   double theta, phi; 1454   double x, y, z; . . . 1464     node(n,0) = cos(theta)*sin(phi - pih); 1465     node(n,1) = sin(theta)*sin(phi - pih); 1466     node(n,2) = cos(phi - pih); 

the header <math.h> puts names global namespace. header <cmath> puts names namespace std. (each allowed put names other namespace well). when code uses <math.h>, way call sin function sin(theta). when code uses <cmath>, way call sin function std::sin(theta) (unless code uses abomination using namespace std). in source2.cpp, #include directive pulls in <cmath>, file should use qualified name , not raw name. or change #include directive pull in <math.h>, source1.cpp does.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -