Search code examples
androidandroid-studioandroid-ndkcmake

How to set version-script file in CMakeLists.txt file of Android Studio


I have a ndk project in Android Studio, and I want to control the exported symbols by this way:

set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=D:\\ProjectFolder\\export_symbols")

or

set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=export_symbols")

This export_symbols file is put together with CMakeLists.txt. The problem is that the compiler would report an error during link and complain that: 'error: no such file or directory'.

So the question is how can I tell the compiler where my export_symbols file is? Any suggestion is welcomed. Thanks.


Solution

  • Solved by adding ${CMAKE_SOURCE_DIR} before the file name.

    set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=" ${CMAKE_SOURCE_DIR} "/export_symbols")