I understand g++ -fPIC option as nicely explainjed in: GCC -fPIC option
I have many source files those are managed through makefile
for build. It's difficult to segregate source files that is meant for being part of an executable or shared library. Can I used -fPIC option of g++ for any file that goes under compilation as:
g++ -c -fPIC ....
and later, if it is a shared library, link with -shared
, otherwise without -shared
for executable.