Linking with the gnu linker ld has some issues about the order the libraries are on the command line. MS linker do a recursive linking, means go along the named libraries as often as there are unresolved symbols.
ld does not.
If you habe -lgl -lglew then glew may add symbols that need imported from gl but because gl has already been used you get an unresolved external message.
To come around this behaviour of ld surround the list of libraries with --start-group --end-group parameter. Then ld goes along the libraries between these tags as long as needed to resolve all externals, stopping if no more symbols can be resolved.
If you call the gcc or g++ compiler driver to do the linking newer versions of gcc/g++, dont know the version number yet, accept -Wl,--start-group -Wl,--end-group to build library groups.