When I tried to make a shared library uses libecec.a, ar shows error with explanation to use -fPIC options on libecec.a so I fixed it by adding line: set(CMAKE_POSITION_INDEPENDENT_CODE ON) into cmake file.