atheros / xbrzscale

Image upscaling commandline tool using xBRZ algorithm
GNU General Public License v3.0
99 stars 17 forks source link

Error when compiling on Mac OS X: no member named 'sqrt' in namespace 'std' #6

Closed elmimmo closed 7 years ago

elmimmo commented 8 years ago

With SDL2 installed, this is what I get when I try to compile on Mac OS X

$ make
g++ -std=c++11 -c -o xbrzscale.o xbrzscale.cpp `sdl2-config --cflags`
g++ -std=c++11 -c -o xbrz/xbrz.o xbrz/xbrz.cpp -DNDEBUG
xbrz/xbrz.cpp:174:12: error: no member named 'sqrt' in namespace 'std'; did you mean 'sbrk'?
    return std::sqrt(square(r_diff) + square(g_diff) + square(b_diff));
           ^~~~~~~~~
           sbrk
/usr/include/unistd.h:582:7: note: 'sbrk' declared here
void    *sbrk(int);
         ^
xbrz/xbrz.cpp:201:12: error: no member named 'sqrt' in namespace 'std'; did you mean 'sbrk'?
    return std::sqrt(square(lumaWeight * y) + square(c_b) + square(c_r));
           ^~~~~~~~~
           sbrk
/usr/include/unistd.h:582:7: note: 'sbrk' declared here
void    *sbrk(int);
         ^
xbrz/xbrz.cpp:237:49: error: no member named 'sqrt' in namespace 'std'
            buffer[i] = static_cast<float>(std::sqrt(square(y) + square(c_b) + square(c_r)));
                                           ~~~~~^
3 errors generated.
make: *** [xbrz/xbrz.o] Error 1
atheros commented 8 years ago

try to add the following on top of xbrz.cpp #include <cmath>

elmimmo commented 8 years ago

Adding that fixes the issue and xbrzscale is compiled successfully.

garrett commented 8 years ago

BTW: This isn't Mac OS X only — I had the same issue (and solution) on Fedora 24.