Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,225
    • Issues 3,225
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 13
    • Merge Requests 13
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #17863

Closed
Open
Opened Mar 30, 2018 by Tom Hughes@thughes

Android NDK always records runtime dependency against stdc++

Regardless of the CMAKE_ANDROID_STL_TYPE chosen (e.g., c++_static), all shared libraries and executables built with the Android NDK are linked against stdc++.

I'm attaching a simple test case that reproduces the issue (change NDK_ROOT in run.sh to point to the NDK and then run run.sh): CMakeLists.txt run.sh test_lib.cc test.cc

Newer versions of clang support the nostdlib++ flag, but the latest stable NDK (16b) does not have a version of clang with that flag: https://reviews.llvm.org/D35780

Also see this NDK issue: https://github.com/android-ndk/ndk/issues/105

As a workaround, you can use the C compiler to link instead of the C++ compiler in your project:

string(REPLACE "CMAKE_CXX_COMPILER" "CMAKE_C_COMPILER" CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
string(REPLACE "CMAKE_CXX_COMPILER" "CMAKE_C_COMPILER" CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
link_libraries(m)

Another option is to set -nodefaultlibs and manually add in the necessary libs: https://github.com/android-ndk/ndk/issues/105#issuecomment-327409972

Edited Apr 02, 2018 by Tom Hughes
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
3.12.0
Milestone
3.12.0 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#17863