鍍金池/ 問答/Android  網絡安全/ cmakelists.txt add_library 里的library nam

cmakelists.txt add_library 里的library name有什么限制嗎?

clipboard.png

我在學習Android NDK,用的是Android Studio,在cmakelists.txt里add_library時,library name如果寫成test就會提示

clipboard.png

不過改成其他名字之后(例如test-lib)就沒問題

請問cmakelists.txt對library name命名有什么限制嗎?還是說這只是Android Studio的問題

回答
編輯回答
短嘆

圖片描述

CMake Error at CMakeLists.txt:22 (add_library):
The target name "test" is reserved or not valid for certain CMake features,
such as generator expressions, and may result in undefined behavior.

問題已解決

2017年12月30日 07:30
編輯回答
笨小蛋

名字應該沒有啥限制。
把你的 CMakeOutput.log 貼出來。

2017年6月21日 00:53
編輯回答
菊外人

沒有限制,但是這邊起的名字要和鏈接時候指定的庫名一致。
如果說test-lib沒有問題,那應該真實鏈接這個庫的時候是:

target_link_libraries(Demo test-lib ...)
2017年9月29日 08:01