问题
I'm trying to compile a program on Windows using MingW (msys2) and it fails with the j0 function. On Linux it compiles no problem. It seems to hate when I use the -std=c++11 flag on the compiler. How can I get this to compile properly and with the -std=c++11 flag on?
Sample code:
#include <cmath>
int main( int argc, char *argv[] )
{
float test = j0( 5 );
}
Output
$ g++ -std=c++11 test.cpp -o test
test.cpp: In function 'int main(int, char**)':
test.cpp:6:21: error: 'j0' was not declared in this scope
float test = j0( 5 );
回答1:
Apparently, MinGW defines the Bessel functions only when __STRICT_ANSI__
is not defined, and it is defined when -std=c++11
is specified. I was able to get your code to compile in MinGW by adding #undef __STRICT_ANSI__
at the top of the file. See https://sourceforge.net/p/mingw-w64/feature-requests/68/
You might also try -std=gnu++11
instead. See https://stackoverflow.com/a/19667112/10077
来源:https://stackoverflow.com/questions/42231558/mingw-c-wont-compile-j0-funciton