于 2011/7/27 17:49, Ruben Van Boxem 写道:
My gcc4.6.1 edition (MinGW64 CRT) don't need this : http://code.google.com/p/pcxprj/
2011/7/27 PcX <email@example.com>
Your gcc-4.6.2's OpenMP (-fopenmp) seems to lack the linker
I have to build OpenMP program using "gcc -fopenmp main.c
-lgomp -lpthread" with your edition.
I believe that is a known limitation for MinGW's -fopenmp. Feel
free to file a bug report with GCC. Is there another mingw-w64
toolchain you know that doesn't require this? fYI, I think
-lgomp is implied by -fopenmp. It's just the -lpthread that
you'd need to add manually.
You are right that "-lgomp is implied by -fopenmp", but the -lgomp
linker option's position is wrong.
If I only use "-lpthread" and if you compiled the program using "gcc
-v -fopenmp main.c -lpthread", you will find that "-lpthread" is
before "-lgomp", so I must write "-lgomp -lpthread".