title: Building Qt for Android, unsupported option '-fPIC' for target 'x86_64-w64-windows-gnu'
body: <p>I am trying to build Qt for Android, following <a href="https://doc.qt.io/qt-5/android-building.html#installing-the-android-sdk-and-ndk-on-windows" rel="nofollow noreferrer">these instructions</a>. My build fails with the error: “clang++.exe: error: unsupported option '-fPIC' for target 'x86_64-w64-windows-gnu'” (see <code>config.log</code> below).</p>
  
  <p>For what appears to be either the same or a related problem <a href="https://github.com/gradle/gradle-native/issues/936" rel="nofollow noreferrer">this post</a> suggests removing the <code>-fPIC</code> flag. I do not know if this is possible for building Qt. (I also don't know how to try it.)</p>
  
  <p><code>config.log</code></p>
  
  <pre><code>Command line: -xplatform android-clang --disable-rpath -nomake tests -nomake examples -android-ndk C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk -android-sdk C:/Users/Adam/AppData/Local/Android/Sdk -no-warnings-are-errors -android-arch armeabi-v71 -verbose
  executing config test verifyspec
  + cd /d C:\Qt\5.13.0\Src\config.tests\verifyspec &amp;&amp; C:\Qt\5.13.0\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" -early "CONFIG += cross_compile" C:/Qt/5.13.0/Src/qtbase/config.tests/verifyspec
  + cd /d C:\Qt\5.13.0\Src\config.tests\verifyspec &amp;&amp; set MAKEFLAGS=&amp; mingw32-make clean &amp;&amp; set MAKEFLAGS=&amp; mingw32-make
  &gt; del verifyspec.obj
  &gt; Could Not Find C:\Qt\5.13.0\Src\config.tests\verifyspec\verifyspec.obj
  &gt; del *~ core *.core
  &gt; Could Not Find C:\Qt\5.13.0\Src\config.tests\verifyspec\*~
  &gt; C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++ -c -D__ANDROID_API__=21 -gcc-toolchain C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 -fno-limit-debug-info -DANDROID_HAS_WSTRING --sysroot=C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/sysroot -isystem C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/sysroot/usr/include/arm-linux-androideabi -isystem C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/sources/cxx-stl/llvm-libc++/include -isystem C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/sources/android/support/include -isystem C:/Users/Adam/AppData/Local/Android/Sdk/android-ndk/sources/cxx-stl/llvm-libc++abi/include -fstack-protector-strong -DANDROID -O2 -O2 -fPIC  -IC:\Qt\5.13.0\Src\qtbase\config.tests\verifyspec -I. -IC:\Qt\5.13.0\Src\qtbase\mkspecs\android-clang -o verifyspec.obj C:\Qt\5.13.0\Src\qtbase\config.tests\verifyspec\verifyspec.cpp
  &gt; clang++.exe: error: unsupported option '-fPIC' for target 'x86_64-w64-windows-gnu'
  &gt; mingw32-make: *** [Makefile:180: verifyspec.obj] Error 1
  </code></pre>
  
  <p>FWIW, I'm otherwise able to build Android apps, including with NDK, on the system. (Also desktop Qt apps.)</p>