代码之家  ›  专栏  ›  技术社区  ›  Rafa

添加日志时,cmakelists.txt(目标链接库)处的cmake错误

  •  2
  • Rafa  · 技术社区  · 7 年前

    我有一个带有cmakelists.txt的ndk项目,看起来是这样的

    cmake_minimum_required(VERSION 3.4.1)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
    
    add_library( # Specifies the name of the library.
            main
    
            # Sets the library as a shared library.
            SHARED
    
            # Provides a relative path to your source file(s).
            main.c)
    
    target_link_libraries(
            android
            log
    )
    

    它遵循了googlesamples github repo上列出的所有ndk示例项目中的模式。我一直在 CMake Error at CMakeLists.txt (target_link_libraries) ,似乎大多数人都是用这条线来解决的

    add_library(debug <files Name>)
    

    但是没有人在日志中添加这个。我做错什么了?

    2 回复  |  直到 7 年前
        1
  •  3
  •   shizhen    7 年前

    在下面添加到 CMakeLists.txt 线以上 target_link_libraries

    find_library( # Sets the name of the path variable.
              log-lib
    
              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )
    

    然后修改 目标链接库 链接android如下 日志 国际清算银行

    target_link_libraries( # Specifies the target library.
                       main
    
                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )
    
        2
  •  -1
  •   zomba    7 年前

    1) 在代码源文件夹中,查找类似“android.mk”或“project.mk”的内容,然后记住它的路径。

    2) 转到Android工作室并点击文件==& gt;链接C++Project与Gealle==Gt;选择Budio系统NDK Bug,然后查找您首先找到的.MK文件。 单击“确定”,然后同步项目。

    推荐文章