0

I have a big problem with a project of mine. In a view words: I want to port the programming language ooRexx to Android. ooRexx is written mostly in C++

I have the NDK installed and so far everything works fine.

First of all I run CMake with this command: cmake -DCMAKE_TOOLCHAIN_FILE=~/coding/android-ndk-r22b/build/cmake/android.toolchain.cmake -DANDROID_ABI="x86" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DANDROID_NATIVE_API_LEVEL=22

there are a view warnings but overall it works. but some warnings are related to my problem so i will post them:

-- Performing Test HAVE_PTHREAD_MUTEX_ERRORCHECK
-- Performing Test HAVE_PTHREAD_MUTEX_ERRORCHECK - Failed
-- Performing Test HAVE_PTHREAD_MUTEX_RECURSIVE
-- Performing Test HAVE_PTHREAD_MUTEX_RECURSIVE - Failed

Next I want to build the whole thing with cmake --build ./

And now there are 2 possible outcomes depending on what Im using in the CMakelists.txt When I leave the CMakeLists.txt as it is theres the following line: set (platform_rexxapi_libs ${ORX_SYSLIB_DL} ${ORX_SYSLIB_PTHREAD})

This line throws the following error: couldnt find -lpthread and the whole build process stops at 13% with this error.

In my research I read that its not necessary to define pthread explicitly when building for Android. So Im removing ${ORX_SYSLIB_PTHREAD} So far so good. Thats helps a bit. The build process goes up to 72% and then stops with posix errors. I get the following errors:

/home/tjk/coding/oorexx/oorexxsvn/main/trunk/interpreter/platform/unix/SystemCommands.cpp:1022:17: error: use of undeclared identifier 'posix_spawnp'
            if (posix_spawnp(&pid, argv[0], NULL, NULL, argv, getEnvironment()) != 0)
                ^
11 errors generated.
make[2]: *** [CMakeFiles/rexx.dir/build.make:2806: CMakeFiles/rexx.dir/interpreter/platform/unix/SystemCommands.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:647: CMakeFiles/rexx.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

i checked and sthe spawn.h library is in the file. Additionally these error will not show up when building for Linux or Windows. So the problem must be related to the Android Toolchain and the CMakeLists.txt

A former colleague already made a working build for Android a few zears ago. But its poorly documented. However he faced the same problem and found out that there needs to be some additional infos in the CMakeLists.txt file.

The additional code should be:

if (ANDROID)
   add_definitions(-DHAVE_PTHREAD_MUTEXATTR_SETTYPE)
   add_definitions(-DHAVE_PTHREAD_MUTEX_RECURSIVE)
endif ()

I added this in the file but it makes no difference. I get the same error at 72%.

Anyone has an idea where the problem is located? Am I providing enough info? Please tell me if I dont. By now its probably obvious that I dont have much experience with CMake, Android. So if additional Info is needed please be so kind and tell me. Ill provide.

Thanks for your help. It is much appreciated.

Best Thomas

tjk
  • 13
  • 3
  • `couldnt find -lpthread` means either in your toolchain, there is no pthreads library or in your toolchain.cmake file, it's not linked. – kiner_shah May 23 '21 at 10:56
  • Can you check if there is pthread library in your toolchain? And if it's there, can you check if it's linked in your toolchain.cmake file. – kiner_shah May 23 '21 at 10:57
  • i will check that! – tjk May 23 '21 at 11:14
  • I found a solution but there are still problems. It was caused by the API-LVL. I build for lvl 22 and the problematic posix function were added with lvl 28. changing api lvl fixed that. Instead I have other troubles with bionic library. its the ```error: unknown type name 'wordexp_t'``` and the error: ```use of undeclared identifier 'crypt"``` Regarding to this link (https://cs.android.com/android/platform/superproject/+/master:bionic/docs/status.md) the functionality is missing. Any idea how i can solve this problem? – tjk May 25 '21 at 09:58
  • In which module are these errors thrown? If it's some external library maybe you can check their website to see how to build for Android - there may be some settings to eliminate these errors. – kiner_shah May 25 '21 at 13:23
  • Hi! Thanks for your help. Bionic is the Android implementation of glabc. Its a very small and fast implementation. The thing is there are a view functionalities missing. Like crypt() and the wordexp function. I searched a little bit around. Regarding crypto in Android there is the possibility of md5 and sha1 but with openssl. So I think I have to write the crypt function by myself. Or find someone who already did this :) the errors are thrown when building the project. it builds fine till 78% and there the crypt and wordexp functions are called in a special file. – tjk May 25 '21 at 15:02
  • But is it some external library which is calling those functions? Like libcurl (a HTTP client library) has a dependency on SSL library like OpenSSL (for secure communication). So, if there is some external library like that used in your project, you can check out that library's home page if it has some information for building for Android. – kiner_shah May 26 '21 at 13:05
  • 1
    Thanks for your input and your time! It turned out, after much trial and error, that these 2 functionalities are not critical and the main developer is ok with missing functionality. Therefore, I removed this 2 functions. – tjk Jun 10 '21 at 10:12

0 Answers0