But didn't help. Still getting the same error message.
You need to use the -fPIC option when building your code also. Any object files that are to be placed into a static library for the x86_64 architecture must be compiled using position-independent code.