question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CPP files don't get compiled

See original GitHub issue

There is a problem with compiling the C code.

When adding this entry in grade build:

externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }

And syncing gradle I get this error message:

Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
Gradle project cmake.path is /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt but that file doesn't exist
/Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt : C/C++ debug|x86 : Failed to activate protocol version: "CMAKE_HOME_DIRECTORY" is set but incompatible with configured source directory value.
/Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt : C/C++ debug|x86 : Waiting for type "handshake".
executing external native build for cmake /Users/houmie/projects/t-android/app/src/main/cpp/CMakeLists.txt

I went then ahead and created the cpp directory and placed an empty text file called CMakeLists.txt. Then I could sync the gradle.

Then I ran:

./gradlew hideSecret -Pkey=Houmie -PkeyName=YourSecretKeyName 

It creates four files under cpp folder. secrets.cpp, sha256.cpp + headers. Secrets is also generated for Kotlin.

So far so good, but when I run it in the project:

val key = Secrets().getYourSecretKeyName(packageName)

It crashes:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libsecrets.so" not found

It hasn’t built it. What am I missing please? Thank you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
houmiecommented, Dec 29, 2020

@ben-j69 I just tested it again. I deleted the cpp folder and ran ./gradlew hideSecret. And it syncs the files over. You were right.

The steps you mentioned is correct. Yesterday I had mistakenly added externalNativeBuild in gradle before running ./gradlew hideSecret. This caused the issue. So the documentation is correct, I didn’t pay enough attention. 😃

Thank you for recommending Cocopods Keys, I will try it out.

0reactions
ben-j69commented, Dec 30, 2020

@houmie thanks for your feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

G++ Not Finding Included .cpp Files When Compiling
Also, you do not usually include .cpp files, you pass them as separate arguments to the compiler and then combine them using the...
Read more >
Only my main.cpp gets compiled - general solution by editing ...
I use visual studio code with the "C/C++" extension and installed Mingw-w64 as compiler. Regardless of the Project (more than one .cpp file) ......
Read more >
Multi-file projects
Don't ever #include .cpp files. Instead, compile them with G++ and link them together. If you #include a .cpp ...
Read more >
C++ Separate Header and Implementation Files
C++ classes (and often function prototypes) are normally split up into two files. The header file has the extension of .h and contains...
Read more >
Multiple File Compilation - Computer Science, FSU
Changes to a file require only that file to be re-compiled (rather than everything), along with the re-linking; Often, libraries are distributed in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found