Code:
$ nm /usr/lib/libm.a | grep cos
00000000 I __imp__acos
00000000 T _acos
00000000 I __imp__acosf
00000000 T _acosf
00000000 I __imp__acosh
00000000 T _acosh
00000000 I __imp__acoshf
00000000 T _acoshf
00000000 I __imp__cos
00000000 T _cos
00000000 I __imp__cosf
00000000 T _cosf
00000000 I __imp__cosh
00000000 T _cosh
00000000 I __imp__coshf
00000000 T _coshf
00000000 I __imp__sincos
00000000 T _sincos
00000000 I __imp__sincosf
00000000 T _sincosf
The 'nm' utility tells you what symbols are defined (or extern) to an object file (or a library).
If it's unresolved in a library, then the letter code will be 'u'
Do that for one of the opengl functions (say glClearColor) to find out which libraries reference it, and which declares it.
Then arrange the library order on the command line so that everything which uses it comes before the one which declares it.