Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error #3

Open
Kushma opened this issue Aug 2, 2022 · 9 comments
Open

Build Error #3

Kushma opened this issue Aug 2, 2022 · 9 comments

Comments

@Kushma
Copy link

Kushma commented Aug 2, 2022

I am using the below command to build, as specified in the Readme.
"./gradlew :library:build"

But I am facing the below error. Attached are the logs.
CMakePlugin.cmakeConfigure - ERRORS:
CMake Error in CMakeLists.txt:
Target "anjay" contains relative path in its INTERFACE_INCLUDE_DIRECTORIES:
"MBEDTLS_INCLUDE_DIR-NOTFOUND"

Please let me know how to resolve this error and successfully build the jar file and the native shared library.
Log.txt

@anuar2k
Copy link
Member

anuar2k commented Aug 2, 2022

Hi,
following line from the log file you provided:

-- Could NOT find mbedTLS (missing: MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_LIBRARIES MBEDTLS_VERSION)

suggest that you don't have mbedTLS installed.
Please install it by executing the command appropriate for your operating system, as described here: https://github.com/AVSystem/Anjay#dependencies

@Mierunski Mierunski mentioned this issue Aug 24, 2022
@Kushma
Copy link
Author

Kushma commented Sep 8, 2022

Hi, following line from the log file you provided:

-- Could NOT find mbedTLS (missing: MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_LIBRARIES MBEDTLS_VERSION)

suggest that you don't have mbedTLS installed. Please install it by executing the command appropriate for your operating system, as described here: https://github.com/AVSystem/Anjay#dependencies

Hi. What if I do not want to include mbedTLS in my module? What all changes will be required in that case?

@anuar2k
Copy link
Member

anuar2k commented Sep 12, 2022

Hi,
Anjay-java was designed to be compiled with security enabled by default. You can compile-in the TLS library, but keep using basic NoSec communication in the runtime. What holds you back from including mbedTLS into the library?

@Kushma
Copy link
Author

Kushma commented Sep 20, 2022

Thank you for your reply. Ya currently I am using NoSec communication.

Can I get some information on Anjay Java's documentation, if any? I see that in Anjay C, there is a complete document. It would be really helpful if we get all 1:1 API mappings and other details in one document.

@Kushma
Copy link
Author

Kushma commented Sep 23, 2022

Hi, I am trying to compile "libanjay-jni.so" separately. And I am seeing this error.

_[100%] Linking CXX shared library libanjay-jni.so
/usr/bin/ld: CMakeFiles/anjay-jni.dir/src/native_access_control.cpp.o: relocation R_X86_64_PC32 against undefined symbol `ZZN3jni16MakeNativeMethodIZNS_17NativeMethodMakerIMZNKS_16NativePeerHelperI19NativeAccessControlS3_FSt10unique_ptrIS3_St14default_deleteIS3_EER7JNIEnv_RNS_6ObjectI11NativeAnjayEEEE15MakeInitializerERKNS_5FieldIS3_lEEPKcPSE_EUlS9_RNSA_IS3_EESD_E_KFvS9_SO_SD_EJEEclISP_EEDaSL_RKT_EUlPS8_PNS_7jobjectESZ_E_EEDaSL_SL_SW_PNSt9enable_ifIXsrSt8is_classISU_E5valueEvE4typeEE6method' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/anjay-jni.dir/build.make:511: recipe for target 'libanjay-jni.so' failed
make[2]: *** [libanjay-jni.so] Error 1
CMakeFiles/Makefile2:81: recipe for target 'CMakeFiles/anjay-jni.dir/all' failed
make[1]: *** [CMakeFiles/anjay-jni.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

Can you please help me address this issue?

@kFYatek
Copy link

kFYatek commented Sep 28, 2022

Hi Kushma,

We cannot reproduce your issue. The library should compile cleanly when configured through just cmake . (or cmake -DJAVA_HOME=<path_to_your_jdk> . if your JDK isn't available in its default location) and it does so on my system.

The CMAKE_POSITION_INDEPENDENT_CODE variable is set in the project's CMakeLists, which should set the -fPIC flag mentioned in the warning appropriately - so it looks that CMake isn't handling your system properly for some reason. This is probably an OS-specific issue.

What operating system are you using? If it's a Linux system, please tell us what distribution in which version it is. Please also tell us the exact command you're using to invoke cmake, and the versions of CMake and JDK if they're not the default ones for the distribution in question.

@Kushma
Copy link
Author

Kushma commented Oct 17, 2022

Hello, thank you for the reply.

I am sticking to using " ./gradlew -Pandroid :library:build" command to build.
I observed that when I change the DTLS_BACKEND to another value other than mbedtls in "native-library/deps/anjay/CMakeLists.txt", and give a build. The DTLS_BACKEND value is not updating in my CMakeCache.txt.

I also observed that the DTLS_BACKEND variable is not getting updated, confirmed from the gradle logs.

Can you pls explain why this is happening? Is there a way I can give a clean build using gradlew?

@kFYatek
Copy link

kFYatek commented Oct 17, 2022

Hi Kushma,

The values specified in CMakeLists.txt for so-called "cache variables" are just defaults, see CMake documentation for set(... CACHE ...) and option().

The specific rules for variable handling in CMake are rather complex, but the general rule is that variables specified on the command line (i.e. cmake -DVAR=value - within the context of Anjay-java this is specified in the Gradle scripts) have the highest priority, then the values already in CMakeCache.txt, if any, then the defaults in CMakeLists.txt. This is designed so that re-running cmake will not change the configuration that you have already set.

Removing CMakeCache.txt (note that there may sometimes be more than one in different directories) is the way to go if you want to reset to the default settings.

@Kushma
Copy link
Author

Kushma commented Nov 14, 2022

Hello, thank you for the clarification.

From Anjay Java to Anjay C++ there is a JNI Iayer and I was working on writing a callback from native back to java. For this, I will need both "JNIEnv *" and "jobject" in arguments but I only see JNIEnv.

Can you please let me know how I can go ahead with writing this JNI callback? And is there a callback in the existing code for reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants