undefinedfix
Sign in

cmakelists.txt add_ Is there any restriction on Library name in library?

bomny edited in Mon, 02 Aug 2021

clipboard.png

I'm learning Android NDK, using Android studio, in cmakelists.txt Add in_ If library name is written as test, it will be prompted

clipboard.png

But it's OK to change it to another name (such as test LIB)

Excuse me? cmakelists.txt Are there any restrictions on Library name naming? Or is it just Android studio

3 Replies
gisshizuku45
commented on Mon, 02 Aug 2021

图片描述

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.

The problem has been solved

Jean717p
commented on Mon, 02 Aug 2021

There should be no restrictions on names. Take your CMakeOutput.log Post it.

user282
commented on Tue, 03 Aug 2021

There is no limit, but the name here should be consistent with the library name specified when linking. If there is no problem with test lib, you should actually link to the library as follows:

target_link_libraries(Demo test-lib ...)
lock This question has been locked and the reply function has been disabled.