For OpenMP, when my code is using the functions in its API (for example, omp_get_thread_num()) without using its directives (such as those #pragma omp ...),
why directly specifying libgomp.a to gcc instead of using -fopenmp doesn't work, such as
gcc hello.c /usr/lib/gcc/i686-linux-gnu/4.4/libgomp.a -o hello
Update: I just found that linking to libgomp.a does not work, but linking to libgomp.so works. Does it mean OpenMP can not be static linked?
Why -fopenmp only works without specifying the library files
gcc hello.c -fopenmp -o hello
Update: In other words, when using -fopenmp, why explicit linking to libgomp.so is not required?
Why does this also compile:
gcc hello.c -L/usr/lib/gcc/i686-linux-gnu/4.4/ -lgomp -o hello
Will this ignore OpenMP directives in the code if there is any?
Thanks and regards!