What does the -fPIC compilation flag does?

2019-07-29 10:27发布

问题:

What the -fpic flag does? I want to install a library (OpenSFM) and it is stated that it will need the Ceres Solver built and installed with the -fPIC compilation flag.

The problem is I already installed the Ceres Solver without the -fPIC flag and other library already depended on it. How can I solve this?

回答1:

A good explaination for -fPIC can be found here.

I think the main question here is whether if you can still go ahead and install OpenSfM without rebuilding Ceres Solver. As far as I know, you can't.

The most straightforward thing you can do is rebuild Ceres Solver and reinstall the PIC version.

cmake .. -DCMAKE_C_FLAGS=fPIC \
   -DCMAKE_CXX_FLAGS=-fPIC \ 
   -DSOMEOTHERARGUMENTSTHATYOUMIGHTHAVE

Let us know how it worked out for you. :)