drowe67 / codec2

Open source speech codec designed for communications quality speech between 700 and 3200 bit/s. The main application is low bandwidth HF/VHF digital radio.
GNU Lesser General Public License v2.1
201 stars 32 forks source link

CMake and Ninja - "missing and no known rule to make it" #56

Closed BadDateAlex closed 4 months ago

BadDateAlex commented 5 months ago

I was trying to import libcodec2 into my project. After importing, there was an error: _ninja: error: 'E:/Android/codec2_talkie-master/libcodec2-android/build/imported-lib/arm64-v8a/libcodec2.so', needed by 'E:/Android/codec2talkie-master/libcodec2-android/build/intermediates/cxx/Debug/4gx1kb3u/obj/arm64-v8a/libCodec2JNI.so', missing and no known rule to make it

I was confused because I run 3 projects(Codec2Talkie、CodecAndroidMaster and my project) on my laptop , all of them have the ninja error, anyone know why it happend? Thanks alot

BadDateAlex commented 5 months ago

After checking stackoverflow(https://stackoverflow.com/questions/54866067/cmake-and-ninja-missing-and-no-known-rule-to-make-it), I found that the error occurred because of the difference between ninja and make. To fix this problem, I need to use "add custom command" but I dont know how to use it, is that comment make sense?

tmiw commented 5 months ago

The Stack Overflow link seems to indicate that you need to add BUILD_BYPRODUCTS to your ExternalProject_Add. I'm not fully sure where the command thing is coming from.

BadDateAlex commented 5 months ago

The Stack Overflow link seems to indicate that you need to add BUILD_BYPRODUCTS to your ExternalProject_Add. I'm not fully sure where the command thing is coming from.

It sounds reasonable ,but I don't know how to add it. Anyway, I don't know why all three projects included libcodec module have the same problem. They may have the same reason cause the problem I think.

BadDateAlex commented 5 months ago

The Stack Overflow link seems to indicate that you need to add BUILD_BYPRODUCTS to your ExternalProject_Add. I'm not fully sure where the command thing is coming from.

What's more, all three projects don't have BUILD_BYPRODUCTS ,I mean ,if the project need it, why don't they reference this statement in their own project?

BadDateAlex commented 5 months ago
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)
set(main_DIR ${CMAKE_SOURCE_DIR})

#添加共享库的格式
add_library(libcodec2 SHARED IMPORTED)
set_target_properties(libcodec2 PROPERTIES IMPORTED_LOCATION
        ${main_DIR}/../../../build/imported-lib/${ANDROID_ABI}/libcodec2.so)

include_directories(${main_DIR}/codec2/)

# Searches for a specified prebuilt library and stores the path as a
## variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

add_library( # Sets the name of the library.
        Codec2JNI
        ## Sets the library as a shared library.
        SHARED
        ## Provides a relative path to your source file(s).
        Codec2JNI.cpp)

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)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries(
        Codec2JNI
        libcodec2
        ${log-lib})

Above is my cmakelist.txt

tmiw commented 5 months ago

Unfortunately I don't really have much experience with Android so I don't think I can be of much help. However, there does seem to be some content in the README about including Codec2 in Android; if that doesn't work for you, it might be a good idea to remove it or otherwise update so that it does work. PRs welcome. :)

What's more, all three projects don't have BUILD_BYPRODUCTS ,I mean ,if the project need it, why don't they reference this statement in their own project?

It's possible those were written with older Android in mind. I'm not familiar with those projects so I can't say for sure.

BadDateAlex commented 5 months ago

Thank you. I 'm a new guy in github, could u tell me what is PR means?

Unfortunately I don't really have much experience with Android so I don't think I can be of much help. However, there does seem to be some content in the README about including Codec2 in Android; if that doesn't work for you, it might be a good idea to remove it or otherwise update so that it does work. PRs welcome. :)

What's more, all three projects don't have BUILD_BYPRODUCTS ,I mean ,if the project need it, why don't they reference this statement in their own project?

It's possible those were written with older Android in mind. I'm not familiar with those projects so I can't say for sure.

tmiw commented 5 months ago

Thank you. I 'm a new guy in github, could u tell me what is PR means?

Pull Request. For example, Codec2 has several open right now. It's a way for contributors to get code they've been working on merged into the project's repository.

BadDateAlex commented 5 months ago

Okkay, I am still trying, I believe there is something I miss. The thing causes this error.

Thank you. I 'm a new guy in github, could u tell me what is PR means?

Pull Request. For example, Codec2 has several open right now. It's a way for contributors to get code they've been working on merged into the project's repository.

tmiw commented 5 months ago

Okkay, I am still trying, I believe there is something I miss. The thing causes this error.

I'd suggest trying what's in the project's README first and if that's not working, the messages that come up may give you an idea of what to try next.