Hi all. I have a code wrote in C++('.cpp') that I'm able to compile without problem in Windows. But when I try to compile in Ubuntu (g++ 4.4) I get the following errors:
Prog.cpp:39: error: ‘min’ was not declared in this scope
Prog.cpp:40: error: ‘max’ was not declared in this scope
The 'min' and 'max' are in the math.h library (I think because I'm not an expert).This is included in the code. searching on google I found differet solution that didn't solve my problem. One of these suggest:
#include <algorithm>
Another solution suggested is to compile adding '-lm'. In both cases I always get the same errors.
Do you know how can I fix my problem?Or, can you write a simple code to substitute at my 'min' and 'max'?
As you can see, min and max are not part of the cmath library.
However: http://cplusplus.com/reference/algorithm/
As you can see now, there is indeed min and max members here. The error makes me believe that you didn't include algorithm or it would give a different error or maybe perhaps you're using the functions incorrectly. If you can send us the entire example, I can probably help further.