SoftwareNetwork / sw

Software Manager. Build System, Build System Generator and Package Manager. C/C++ and other languages. Tools and libraries for Software Management.
https://software-network.org
Other
113 stars 24 forks source link

Integrate sw for arm build #97

Closed Ottunger closed 2 years ago

Ottunger commented 2 years ago

Hello,

I'm trying to build a project using Tesseract and OpenCV for android. The windows build works perfectly fine, and I'd like to use the NDK toolchain to build natively for android (and then add a JNI calling class, but that's out of this scope).

I don't find a way to tell sw to use the toolchain of the NDK. I've placed all executables of the toolchain in my PATH, and I had to modify SWConfig.cmake to read:

set(sw_platform_args
        ${storage_dir}
        ${stsh}
        -platform arm64
        ${mt_flag}
        -compiler clang-12.0
        ${os}
        -d "${wdir}"
    )

because I couldn't find another way to pass arm64.

Anyways, now I'm stuck with:

Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.a55044-0.0.29.dll): Exception in file D:/dev/cppan2/client2/src/sw/driver/target/native.cpp:772, function findCompiler: Librarian not found

And looking at this repo, this means the "lib" is not found in the settings, so can you tell me how to reference the lib?

I don't mind to temporarily modify SWConfig.cmake to already prove the feasibility end to end, and then make it cleaner if OK.

egorpugin commented 2 years ago

Hi,

Do you have small example or repro? So I could test it myself.

It seems, cmake thing is easy to fix.

As for lib (or Librarian) you can try to add -DSW_DEBUG=1 or what variable it is in SWConfig.cmake, so it will print sw command. Next, run that command with --trace flag and attach output here.

Ottunger commented 2 years ago

Looks like the built command is: C:/Windows/System32/sw.exe -static -platform arm64 -compiler clang-12.0 -linker ld -d C:/Users/Ottunger/Desktop/dev/satoris-ocr/cmake-build-release-ndk-23/.sw/cmake -config r integrate -cmake-deps C:/Users/Ottunger/Desktop/dev/satoris-ocr/cmake-build-release-ndk-23/.sw/cmake/sw.txt -cmake-file-version 6

Anyways, you can find the repo that I'm trying to build here: https://gitlab.satoris.lu/satoris/satoris-ocr .

Let me know if anything!

egorpugin commented 2 years ago

I see. Try to install lld package (or take lld linker from llvm). I hardcoded this some time ago because of poor ld performance on big projects.

egorpugin commented 2 years ago

Also it's better to use non-master (release) version of tess. https://gitlab.satoris.lu/satoris/satoris-ocr/-/blob/master/CMakeLists.txt#L15 I did not update master branch for some time, but there is v5.2.0. https://software-network.org/org.sw.demo.google.tesseract.libtesseract

Ottunger commented 2 years ago

Okay, let me have a look. NDK provides ld.exe and ld.lld.exe should I force the command to contain these?

egorpugin commented 2 years ago

NDK provides ld.exe and ld.lld.exe should I force the command to contain these?

I don't think it will catch it from cmd.

Ottunger commented 2 years ago

Hmmm used tesseract 5.2.0, that's ok.

For the android build though, still can't get it OK.

If I leave x64 as platform I get the following:

Exception in file D:/dev/cppan2/client2/src/sw/builder/command.cpp:825, function execute1: When executing: [org.sw.demo.gif-5.2.1]/gifalloc.c
In file included from C:/Users/Ottunger/.sw/storage/pkg/89/dc/64e7/src/sdir/gifalloc.c:14:
In file included from C:/Users/Ottunger/.sw/storage/pkg/89/dc/64e7/src/sdir/gif_lib_private.h:13:
C:/Users/Ottunger/.sw/storage/pkg/89/dc/64e7/src/sdir/gif_hash.h:12:10: fatal error: 'unistd.h' file not found
#include <unistd.h>
         ^~~~~~~~~~
1 error generated.
command failed: exit code = 1

Exception in file D:/dev/cppan2/client2/src/sw/builder/command.cpp:825, function execute1: When executing: [org.sw.demo.openssl.ssl-1.1.1.14]/ssl/ssl_sess.c
In file included from C:/Users/Ottunger/.sw/storage/pkg/23/57/64e2/src/sdir/ssl/ssl_sess.c:14:
In file included from C:/Users/Ottunger/.sw/storage/pkg/03/19/b62d/src/sdir/include/internal/refcount.h:21:
C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/include/stdatomic.h:15:2: error: <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
#error <stdatomic.h> is not yet supported when compiling as C, but this is planned for a future release.
 ^
In file included from C:/Users/Ottunger/.sw/storage/pkg/23/57/64e2/src/sdir/ssl/ssl_sess.c:14:
In file included from C:/Users/Ottunger/.sw/storage/pkg/03/19/b62d/src/sdir/include/internal/refcount.h:21:
In file included from C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/include/stdatomic.h:19:
In file included from C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/include/yvals.h:9:
C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/include/yvals_core.h:23:2: error: STL1003: Unexpected compiler, expected C++ compiler.
#error STL1003: Unexpected compiler, expected C++ compiler.
 ^

If I force platform arm64

Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.f33386-0.0.29.dll): Exception in file D:/dev/cppan2/client2/src/sw/driver/target/native.cpp:772, function findCompiler: Librarian not found
sw command: C:/Windows/System32/sw.exe -shared -platform arm64 -compiler clang-14.0 -d C:/Users/Ottunger/Desktop/dev/satoris-ocr/cmake-build-release-ndk-25/.sw/cmake -config r integrate -cmake-deps C:/Users/Ottunger/Desktop/dev/satoris-ocr/cmake-build-release-ndk-25/.sw/cmake/sw.txt -cmake-file-version 6
CMake Error at C:/Users/Ottunger/.sw/storage/etc/sw/static/SWConfig.cmake:235 (message):
  sw: non-zero exit code: 1

So, could you tell me how I can force which ld to use, even by modifying SWConfig.cmake? Supposing this error means ld is not found of course!

egorpugin commented 2 years ago

The problem is that packages do not support android. I did not do any testing for it, because of lack of time. To try to add android support I need small repro. I'll take your example.

Ottunger commented 2 years ago

Sure, that seems fair! Let me know if I can help or test anything.

Must say, this project is already great job so far :)

egorpugin commented 2 years ago

How do you run that cmake? From Android studio?

Ottunger commented 2 years ago

From CLion, by using a "system" toolchain, and referencing clang binaries. I added -DCMAKE_TOOLCHAIN_FILE -DANDROID_ABI -DANDROID_PLATFORM

From Android studio, I couldn't get SW to find clang binary, although it is in my PATH. Says "Cannot find compiler org.LLVM.clang"

egorpugin commented 2 years ago

So, I tried android build with sw itself.

Create sw.cpp

void build(Solution &s)
{
    auto &ocr = s.addStaticLibrary("ocr");
    ocr += cpp17;
    ocr +=
        "opencv_hough_lines.cpp",
        "process.cpp",
        "TD1Builder.cpp",
        "ocr.cpp"
        ;
    ocr += "org.sw.demo.intel.opencv.imgcodecs"_dep;
}

Create sw toolchain file for android win2android.json, fix your sdk paths:

{
    "name": "win2android",
    "native": {
        "program": {
            "asm": "org.LLVM.clang",
            "c":
            {
                "package": "org.LLVM.clang",
                "command":
                {
                    "do_not_add_target_argument": "1",
                    "program": "d:/dev/android/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android30-clang.cmd"
                }
            },
            "cpp":
            {
                "package": "org.LLVM.clangpp",
                "command":
                {
                    "do_not_add_target_argument": "1",
                    "program": "d:/dev/android/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android30-clang++.cmd"
                }
            },
            "lib": "org.LLVM.ar",
            "link":
            {
                "package": "org.LLVM.clang",
                "command":
                {
                    "do_not_add_target_argument": "1",
                    "program": "d:/dev/android/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android30-clang++.cmd"
                }
            }
        },
        "stdlib": {
            "c": null,
            "compiler": null,
            "kernel": null,
            "cpp": null
        }
    },
    "os": {
        "kernel": "org.torvalds.linux",
        "version": "5.17"
    }
}

Run

sw build -settings-file win2android.json

Now sw says that it must complete platform checks (like cmake does):

Performing 9 check(s): org.sw.demo.jpeg-9.5.0 (jpeg), config 772283
[5/9] Check WORDS_BIGENDIAN requires to be set up manually
[8/9] Check HAVE_SIZEOF_UNSIGNED_CHAR requires to be set up manually
[9/9] Check HAVE_SIZEOF_UNSIGNED_SHORT requires to be set up manually
Waiting for completing cc checks.
Run 'D:/dev/swst/etc/sw/checks/772283/cc/run.sh' and press and key to continue...

What does it mean? Libraries do such checks on configure stage. For example, check pointer size on this platform, size of some types. To do this, sw needs to run small check binaries on target (!) platform. So you need to run android arm64 emulator or real device, write some script to transfer check files there, run checks command and return files back. You need to add following flags to sw -wait-for-cc-checks -cc-checks-command win2android_aarch64_checks.bat. To run android emulator use tools/emulator.exe. To copy files and run commands use platform-tools/adb push/shell/etc.

For some reason arm64 emulator does not start for me, so you are kindly encouraged to do this and provide feedback.

Ottunger commented 2 years ago

Hmmm thanks for the tests so far.

So, trying to understand because as much as I understand the basic concepts of creating a C/C++ program or library, I'm all new to SW. I added the file sw.cpp, but doesn't it need any headers?

Anyways, I could fix the paths and run your command to build. After having manually for now ran the checks and imported the results, I re-ran the command and I got:

C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build --settings-file win2android.json
Performing 43 check(s): org.sw.demo.tiff-4.4.0 (tiff), config 313738
Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.e0ea5f-0.0.29.dll): Exception in file C:/Users/Ottunger/.sw/storag
e/pkg/b2/ef/b415/src/sdir/sw.cpp:115, function build: no type: 0, 0

Code at that position is

else if (!tiff.DryRun)
        throw SW_RUNTIME_ERROR("no type: " + tiff.Variables["SIZEOF_SIGNED_INT"].toString() + ", " + tiff.Variables["SIZEOF_SIGNED_LONG"].toString());

making me think all configure checks have not been registered? Can I check this?

egorpugin commented 2 years ago

Try to remove c:\users\u\.sw\storage\etc\sw\checks (copy to checks1 dir to not lost them). Re-run command with --print-checks and post log here.

sw build --settings-file win2android.json --print-checks

Your error definitely means that SIZEOF_SIGNED_INT was not determined.


I added the file sw.cpp, but doesn't it need any headers?

Sw will downloaded needed headers.

Ottunger commented 2 years ago
C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build --settings-file win2android.json --print-checks
Performing 14 check(s): org.sw.demo.google.breakpad.common.windows-master (breakpad), config 156559
Performing 89 check(s): pub.egorpugin.llvm_project.llvm.support_lite-14.0.6 (support_lite), config 156559
Performing 36 check(s): org.sw.demo.xz_utils.lzma-5.2.5 (lzma), config 156559
Performing 134 check(s): org.sw.demo.c_ares-1.18.1 (c_ares), config 156559
Performing 2 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (libcurl), config 156559
Performing 203 check(s): org.sw.demo.libarchive.libarchive-3.6.1 (libarchive), config 156559
Performing 6 check(s): org.sw.demo.gnu.nettle.eccdata-3.6.0 (nettle), config 156559
Performing 36 check(s): org.sw.demo.xmlsoft.libxml2-2.9.12 (libxml2), config 156559
Performing 21 check(s): org.sw.demo.gnu.iconv.libiconv-1.16.0 (libiconv), config 156559
Performing 105 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (libcurl), config 116146
Performing 55 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (c_ares), config 116146
Performing 220 check(s): org.sw.demo.libarchive.libarchive-3.6.1 (libarchive), config 116146
Performing 6 check(s): org.sw.demo.gnu.nettle.eccdata-3.6.0 (nettle), config 116146
Performing 41 check(s): org.sw.demo.xmlsoft.libxml2-2.9.12 (libxml2), config 116146
Performing 22 check(s): org.sw.demo.xz_utils.lzma-5.2.5 (lzma), config 116146
Performing 21 check(s): org.sw.demo.gnu.iconv.libiconv-1.16.0 (libiconv), config 116146
Performing 64 check(s): pub.egorpugin.llvm_project.llvm.support_lite-14.0.6 (support_lite), config 116146
Performing 3 check(s): org.sw.demo.c_ares-1.18.1 (c_ares), config 116146
Performing 20 check(s): org.sw.demo.nghttp2-1.48.0 (nghttp2), config 116146
Performing 6 check(s): org.sw.demo.libssh2-1.10.0 (libssh2), config 116146
Performing 131 check(s): org.sw.demo.openldap.lber-2.6.2 (ldap), config 116146
Performing 20 check(s): org.sw.demo.nghttp2-1.48.0 (nghttp2), config 156559
Performing 6 check(s): org.sw.demo.libssh2-1.10.0 (libssh2), config 156559
Performing 131 check(s): org.sw.demo.openldap.lber-2.6.2 (ldap), config 156559
Performing 210 check(s): org.sw.demo.python.lib-3.10.5 (lib), config 116146
Performing 2 check(s): org.sw.demo.expat-2.4.8 (expat), config 116146
Performing 7 check(s): org.sw.demo.gnu.gettext.intl-0.21.0 (intl), config 116146
Performing 209 check(s): org.sw.demo.python.lib-3.10.5 (lib), config 156559
Performing 2 check(s): org.sw.demo.expat-2.4.8 (expat), config 156559
Performing 7 check(s): org.sw.demo.gnu.gettext.intl-0.21.0 (intl), config 156559
Performing 9 check(s): org.sw.demo.jpeg-9.5.0 (jpeg), config 313738
[4/9] Check WORDS_BIGENDIAN requires to be set up manually
Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.66e115-0.0.29.dll): Exception in file D:/dev/cppan2/client2/src/sw
/driver/checks.cpp:556, function performChecks: Some manual checks are missing, please set them in order to continue. Manual checks file: C:\Users\Ottunger\.sw\storage\etc\sw\checks\313738\checks.3.txt.manual.txt. You also may copy 
produced binaries to target platform and run them there using prepared script. Results will be gathered into required file. Binaries directory: C:\Users\Ottunger\.sw\storage\etc\sw\checks\313738\cc

After having filled in result,

C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build --settings-file win2android.json --print-checks
Performing 43 check(s): org.sw.demo.tiff-4.4.0 (tiff), config 313738
Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.e0ea5f-0.0.29.dll): Exception in file C:/Users/Ottunger/.sw/storag
e/pkg/b2/ef/b415/src/sdir/sw.cpp:115, function build: no type: 0, 0

Question, in your win2android.json file, is the "os" the target config or the compiler config? I saw it filled automatically with platform = x86_64, which seems wrong if target, or I should put kernel = windows if compiler? If I change in the json to os.arch = aarch64 and os.kernel = com.Microsoft.Windows.NT, I get:

C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build --settings-file win2android.json --print-checks 
Performing 14 check(s): org.sw.demo.google.breakpad.common.windows-master (breakpad), config 156559
Performing 89 check(s): pub.egorpugin.llvm_project.llvm.support_lite-14.0.6 (support_lite), config 156559
Performing 36 check(s): org.sw.demo.xz_utils.lzma-5.2.5 (lzma), config 156559
Performing 134 check(s): org.sw.demo.c_ares-1.18.1 (c_ares), config 156559
Performing 2 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (libcurl), config 156559
Performing 203 check(s): org.sw.demo.libarchive.libarchive-3.6.1 (libarchive), config 156559
Performing 6 check(s): org.sw.demo.gnu.nettle.eccdata-3.6.0 (nettle), config 156559
Performing 36 check(s): org.sw.demo.xmlsoft.libxml2-2.9.12 (libxml2), config 156559
Performing 21 check(s): org.sw.demo.gnu.iconv.libiconv-1.16.0 (libiconv), config 156559
Performing 105 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (libcurl), config 116146
Performing 55 check(s): org.sw.demo.badger.curl.libcurl-7.84.0 (c_ares), config 116146
Performing 220 check(s): org.sw.demo.libarchive.libarchive-3.6.1 (libarchive), config 116146
Performing 6 check(s): org.sw.demo.gnu.nettle.eccdata-3.6.0 (nettle), config 116146
Performing 41 check(s): org.sw.demo.xmlsoft.libxml2-2.9.12 (libxml2), config 116146
Performing 22 check(s): org.sw.demo.xz_utils.lzma-5.2.5 (lzma), config 116146
Performing 21 check(s): org.sw.demo.gnu.iconv.libiconv-1.16.0 (libiconv), config 116146
Performing 64 check(s): pub.egorpugin.llvm_project.llvm.support_lite-14.0.6 (support_lite), config 116146
Performing 20 check(s): org.sw.demo.nghttp2-1.48.0 (nghttp2), config 156559
Performing 6 check(s): org.sw.demo.libssh2-1.10.0 (libssh2), config 156559
Performing 131 check(s): org.sw.demo.openldap.lber-2.6.2 (ldap), config 156559
Performing 3 check(s): org.sw.demo.c_ares-1.18.1 (c_ares), config 116146
Performing 20 check(s): org.sw.demo.nghttp2-1.48.0 (nghttp2), config 116146
Performing 6 check(s): org.sw.demo.libssh2-1.10.0 (libssh2), config 116146
Performing 131 check(s): org.sw.demo.openldap.lber-2.6.2 (ldap), config 116146
Performing 210 check(s): org.sw.demo.python.lib-3.10.5 (lib), config 116146
Performing 7 check(s): org.sw.demo.gnu.gettext.intl-0.21.0 (intl), config 116146
Performing 2 check(s): org.sw.demo.expat-2.4.8 (expat), config 116146
Performing 209 check(s): org.sw.demo.python.lib-3.10.5 (lib), config 156559
Performing 7 check(s): org.sw.demo.gnu.gettext.intl-0.21.0 (intl), config 156559
Performing 2 check(s): org.sw.demo.expat-2.4.8 (expat), config 156559
Performing 9 check(s): org.sw.demo.jpeg-9.5.0 (jpeg), config 143380
Performing 43 check(s): org.sw.demo.tiff-4.4.0 (tiff), config 143380
Exception in file D:/dev/cppan2/client2/src/sw/driver/module.cpp:120, function operator (): error in module (C:/Users/Ottunger/.sw/storage/tmp/cfg/116146/loc.sw.self.e0ea5f-0.0.29.dll): Exception in file C:/Users/Ottunger/.sw/storag
e/pkg/b2/ef/b415/src/sdir/sw.cpp:115, function build: no type: 0, 0

without even asking for performing checks. (Checks directory has been cleaned before this command with new json).

Also, I actually get a file "org.sw.demo.tiff-4.4.0.tiff.txt" generated, with contents:

HAVE_ASSERT_H 0 14754637843035269323
HAVE_DLFCN_H 0 12111039790322267578
HAVE_FCNTL_H 0 1520475588362036942
HAVE_FLOOR 0 16113805470528153656
HAVE_GETOPT 0 2803903936530088795
HAVE_INT16 0 10939388307609729305
HAVE_INT32 0 8312951742785138580
HAVE_INT8 0 9539540482955575761
HAVE_INTTYPES_H 0 326838618669140684
HAVE_IO_H 0 5517422477616172763
HAVE_ISASCII 0 17986137087511070563
HAVE_LFIND 0 12992156702090188753
HAVE_LIMITS_H 0 18316307855765408607
HAVE_MALLOC_H 0 3660884772115965739
HAVE_MEMMOVE 0 8470078856218122719
HAVE_MEMORY_H 0 2247914386020432592
HAVE_MEMSET 0 15917842289546625216
HAVE_MMAP 0 15803312415150136433
HAVE_POW 0 4767539584679023740
HAVE_PTRDIFF_T 0 10964718297349446684
HAVE_SEARCH_H 0 3418044324070865213
HAVE_SETMODE 0 3232520863721657676
HAVE_SIGNED_INT 0 9366287256542546158
HAVE_SIGNED_LONG 0 17153139437960448011
HAVE_SIGNED_LONG_LONG 0 15185966248171223254
HAVE_SIGNED_SHORT 0 10273514400890468865
HAVE_SIZEOF_INT16 0 10939388307609729305
HAVE_SIZEOF_INT32 0 8312951742785138580
HAVE_SIZEOF_INT8 0 9539540482955575761
HAVE_SIZEOF_PTRDIFF_T 0 10964718297349446684
HAVE_SIZEOF_SIGNED_INT 0 9366287256542546158
HAVE_SIZEOF_SIGNED_LONG 0 17153139437960448011
HAVE_SIZEOF_SIGNED_LONG_LONG 0 15185966248171223254
HAVE_SIZEOF_SIGNED_SHORT 0 10273514400890468865
HAVE_SIZEOF_SIZE_T 0 8115718761240997844
HAVE_SIZEOF_UNSIGNED_CHAR_P 0 12667971229563927423
HAVE_SIZEOF_UNSIGNED_INT 0 17660110412603793544
HAVE_SIZEOF_UNSIGNED_LONG 0 14500031678524706725
HAVE_SIZEOF_UNSIGNED_LONG_LONG 0 6919767266345332216
HAVE_SIZEOF_UNSIGNED_SHORT 0 17625000684751060776
HAVE_SIZEOF_VOID_P 0 18297289346866248323
HAVE_SIZE_OF_INT16 0 10939388307609729305
HAVE_SIZE_OF_INT32 0 8312951742785138580
HAVE_SIZE_OF_INT8 0 9539540482955575761
HAVE_SIZE_OF_PTRDIFF_T 0 10964718297349446684
HAVE_SIZE_OF_SIGNED_INT 0 9366287256542546158
HAVE_SIZE_OF_SIGNED_LONG 0 17153139437960448011
HAVE_SIZE_OF_SIGNED_LONG_LONG 0 15185966248171223254
HAVE_SIZE_OF_SIGNED_SHORT 0 10273514400890468865
HAVE_SIZE_OF_SIZE_T 0 8115718761240997844
HAVE_SIZE_OF_UNSIGNED_CHAR_P 0 12667971229563927423
HAVE_SIZE_OF_UNSIGNED_INT 0 17660110412603793544
HAVE_SIZE_OF_UNSIGNED_LONG 0 14500031678524706725
HAVE_SIZE_OF_UNSIGNED_LONG_LONG 0 6919767266345332216
HAVE_SIZE_OF_UNSIGNED_SHORT 0 17625000684751060776
HAVE_SIZE_OF_VOID_P 0 18297289346866248323
HAVE_SIZE_T 0 8115718761240997844
HAVE_SNPRINTF 0 14679156321743176240
HAVE_SQRT 0 10804981354684966375
HAVE_STDDEF_H 0 5298595375018012678
HAVE_STDINT_H 0 9276858803468379881
HAVE_STDIO_H 0 8895671926270453775
HAVE_STRCASECMP 0 15179752521689409786
HAVE_STRCHR 0 10101517737177932399
HAVE_STRINGS_H 0 10755401001214698358
HAVE_STRING_H 0 302612414745236033
HAVE_STRRCHR 0 1084880180729446706
HAVE_STRSTR 0 16693854418578898586
HAVE_STRTOL 0 15866763364778878884
HAVE_STRTOULL 0 7356553903209430024
HAVE_SYSTIME_H 0 6923834566692264016
HAVE_SYSTYPES_H 0 15590729096308629249
HAVE_SYS_TIME_H 0 6923834566692264016
HAVE_SYS_TYPES_H 0 15590729096308629249
HAVE_UNISTD_H 0 15245665552873438715
HAVE_UNSIGNED_CHAR_P 0 12667971229563927423
HAVE_UNSIGNED_INT 0 17660110412603793544
HAVE_UNSIGNED_LONG 0 14500031678524706725
HAVE_UNSIGNED_LONG_LONG 0 6919767266345332216
HAVE_UNSIGNED_SHORT 0 17625000684751060776
HAVE_VOID_P 0 18297289346866248323
SIZEOF_INT16 0 10939388307609729305
SIZEOF_INT16_CODE 0 10939388307609729305
SIZEOF_INT32 0 8312951742785138580
SIZEOF_INT32_CODE 0 8312951742785138580
SIZEOF_INT8 0 9539540482955575761
SIZEOF_INT8_CODE 0 9539540482955575761
SIZEOF_PTRDIFF_T 0 10964718297349446684
SIZEOF_PTRDIFF_T_CODE 0 10964718297349446684
SIZEOF_SIGNED_INT 0 9366287256542546158
SIZEOF_SIGNED_INT_CODE 0 9366287256542546158
SIZEOF_SIGNED_LONG 0 17153139437960448011
SIZEOF_SIGNED_LONG_CODE 0 17153139437960448011
SIZEOF_SIGNED_LONG_LONG 0 15185966248171223254
SIZEOF_SIGNED_LONG_LONG_CODE 0 15185966248171223254
SIZEOF_SIGNED_SHORT 0 10273514400890468865
SIZEOF_SIGNED_SHORT_CODE 0 10273514400890468865
SIZEOF_SIZE_T 0 8115718761240997844
SIZEOF_SIZE_T_CODE 0 8115718761240997844
SIZEOF_UNSIGNED_CHAR_P 0 12667971229563927423
SIZEOF_UNSIGNED_CHAR_P_CODE 0 12667971229563927423
SIZEOF_UNSIGNED_INT 0 17660110412603793544
SIZEOF_UNSIGNED_INT_CODE 0 17660110412603793544
SIZEOF_UNSIGNED_LONG 0 14500031678524706725
SIZEOF_UNSIGNED_LONG_CODE 0 14500031678524706725
SIZEOF_UNSIGNED_LONG_LONG 0 6919767266345332216
SIZEOF_UNSIGNED_LONG_LONG_CODE 0 6919767266345332216
SIZEOF_UNSIGNED_SHORT 0 17625000684751060776
SIZEOF_UNSIGNED_SHORT_CODE 0 17625000684751060776
SIZEOF_VOID_P 0 18297289346866248323
SIZEOF_VOID_P_CODE 0 18297289346866248323
SIZE_OF_INT16 0 10939388307609729305
SIZE_OF_INT32 0 8312951742785138580
SIZE_OF_INT8 0 9539540482955575761
SIZE_OF_PTRDIFF_T 0 10964718297349446684
SIZE_OF_SIGNED_INT 0 9366287256542546158
SIZE_OF_SIGNED_LONG 0 17153139437960448011
SIZE_OF_SIGNED_LONG_LONG 0 15185966248171223254
SIZE_OF_SIGNED_SHORT 0 10273514400890468865
SIZE_OF_SIZE_T 0 8115718761240997844
SIZE_OF_UNSIGNED_CHAR_P 0 12667971229563927423
SIZE_OF_UNSIGNED_INT 0 17660110412603793544
SIZE_OF_UNSIGNED_LONG 0 14500031678524706725
SIZE_OF_UNSIGNED_LONG_LONG 0 6919767266345332216
SIZE_OF_UNSIGNED_SHORT 0 17625000684751060776
SIZE_OF_VOID_P 0 18297289346866248323
WORDS_BIGENDIAN 0 3003110902137576763

Not sure if the zeroes are expected.

egorpugin commented 2 years ago

is the "os" the target config or the compiler config

In json file this is target config.

Not sure if the zeroes are expected.

Size of int, of course, cannot be zero.

If I change in the json to os.arch = aarch64 and os.kernel = com.Microsoft.Windows.NT

If you change it in config, it will use MSVC compiler probably and that tiff error 0 0 shows that I also did not test arm64 windows build yet. Compiler is available, but i do not have win arm64 host to run checks again.

Ottunger commented 2 years ago

Not sure what I should test now to be honest?

Maybe it would work if I force the results of the checks manually, but I'd like to know why they return zeroes. Any idea?

egorpugin commented 2 years ago

It is cached for some reason already. Just remove checks dir. To set checks manually add parameter -wait-for-cc-checks. It will point to some dir. Open it, you will see text file. Open it, replace ? with actuabl values. Press enter in sw window.

Ottunger commented 2 years ago

The thing is, even when I remove checks dir and I add --wait-for-cc-checks, the process does not stop, it goes all the way to the fault. Tried removing .sw folder in the folder where I do the command, but no luck there either.

egorpugin commented 2 years ago

What is your json config?

Ottunger commented 2 years ago
{
  "name": "win2android",
  "native": {
    "program": {
      "asm": "org.LLVM.clang",
      "c":
      {
        "package": "org.LLVM.clang",
        "command":
        {
          "do_not_add_target_argument": "1",
          "program": "C:/Users/Ottunger/Desktop/dev/cmdline-tools/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang.cmd"
        }
      },
      "cpp":
      {
        "package": "org.LLVM.clangpp",
        "command":
        {
          "do_not_add_target_argument": "1",
          "program": "C:/Users/Ottunger/Desktop/dev/cmdline-tools/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang++.cmd"
        }
      },
      "lib": "org.LLVM.ar",
      "link":
      {
        "package": "org.LLVM.clang",
        "command":
        {
          "do_not_add_target_argument": "1",
          "program": "C:/Users/Ottunger/Desktop/dev/cmdline-tools/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang++.cmd"
        }
      }
    },
    "stdlib": {
      "c": null,
      "compiler": null,
      "kernel": null,
      "cpp": null
    }
  },
  "os": {
    "arch":"aarch64",
    "kernel": "org.torvalds.linux"
  }
}
egorpugin commented 2 years ago

1.

    "os": {
        "kernel": "org.torvalds.linux",
        "version": "5.17"
    }
  1. You want arm64 but you have
    bin/x86_64-linux-android21-..."

    instead of

    bin/aarch64-linux-android21-..."
egorpugin commented 2 years ago

Also try to use updated binary. sw.client.sw-1.0.0.exe.zip

Ottunger commented 2 years ago

Oooook, so:

my mistake for aarch64, that said it didn't change anything. Using the updated client yields much better results, and compilation starts!

However, I think the libs are not well made available (see opencv error), and the standard lib behaves weirdly?

C:/Users/Ottunger/Desktop/dev/satoris-ocr/TD1Builder.cpp:56:17: error: implicit instantiation of undefined template 'std::basic_string<char>'
    std::string _expiry_date;
                ^
C:/Users/Ottunger/Desktop/dev/cmdline-tools/sdk/ndk/25.0.8775105/toolchains/llvm/prebuilt/windows-x86_64/bin/../sysroot/usr/include/c++/v1/iosfwd:209:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;

In file included from C:/Users/Ottunger/Desktop/dev/satoris-ocr/opencv_hough_lines.cpp:2:
C:/Users/Ottunger/Desktop/dev/satoris-ocr/opencv_hough_lines.h:4:10: fatal error: 'opencv2/video.hpp' file not found
#include <opencv2/video.hpp>
         ^~~~~~~~~~~~~~~~~~~
egorpugin commented 2 years ago

Can you send me checks dir, so I also try actual building?

Ottunger commented 2 years ago

checks.zip

This is what I have!

egorpugin commented 2 years ago

Btw, you don't have <string> include in TD1Builder.h.

C:/Users/Ottunger/Desktop/dev/satoris-ocr/TD1Builder.cpp:56:17: error: implicit instantiation of undefined template 'std::basic_string<char>'
    std::string _expiry_date;

In file included from C:/Users/Ottunger/Desktop/dev/satoris-ocr/opencv_hough_lines.cpp:2:
C:/Users/Ottunger/Desktop/dev/satoris-ocr/opencv_hough_lines.h:4:10: fatal error: 'opencv2/video.hpp' file not found
#include <opencv2/video.hpp>
         ^~~~~~~~~~~~~~~~~~~

Add opencv video dependency in sw.cpp.

egorpugin commented 2 years ago

checks.zip

Can you re-run sw with --print-checks because at the moment I cannot determine what check dir is for. One can be host check and other for android.

Ottunger commented 2 years ago

Hmmm really strange that I now need <string> where a build for x86_64 works without anything? Is there an addes stdlib by default there?

Anyways, the complete command gives

C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build --settings-file win2android.json --print-checks
[4/3146] [org.sw.demo.intel.opencv.imgproc-4.6.0]/modules/imgproc/src/approx.cpp
[5/3146] [org.sw.demo.uclouvain.openjpeg.openjp2-2.5.0]/src/lib/openjp2/tgt.c
[6/3146] [org.sw.demo.xz_utils.lzma-5.2.5]/src/liblzma/check/crc64_table.c
[7/3146] [org.sw.demo.google.brotli-1.0.9]/enc/block_splitter.c
[8/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/rc4/rc4_enc.c
[9/3146] [org.sw.demo.openldap.ldap-2.6.2]/libraries/libldap/fetch.c
[10/3146] [org.sw.demo.jpeg-9.5.0]/jdtrans.c
[11/3146] [org.sw.demo.Esri.lerc-3.0.0]/src/LercLib/Lerc2.cpp
[12/3146] [org.sw.demo.badger.curl.libcurl-7.84.0]/lib/http_aws_sigv4.c
[13/3146] [org.sw.demo.mdadams.jasper-3.0.6]/base/jas_malloc.c
[14/3146] [org.sw.demo.webmproject.webp-1.1.0]/src/dsp/dec.c
[15/3146] [ocr-0.0.1]/ocr.cpp
[16/3146] [org.sw.demo.malaterre.GDCM.jpeg12-3.0.14]/Utilities/gdcmjpeg/jdhuff.c
[17/3146] [org.sw.demo.jpeg-9.5.0]/jdmaster.c
[18/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/pkcs12/p12_mutl.c
[19/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/rsa/rsa_saos.c
[20/3146] [org.sw.demo.malaterre.GDCM.gdcm-3.0.14]/Source/MediaStorageAndFileFormat/gdcmLookupTable.cxx
[21/3146] [org.sw.demo.malaterre.GDCM.jpeg12-3.0.14]/Utilities/gdcmjpeg/jcmaster.c
[22/3146] [ocr-0.0.1]/process.cpp
[23/3146] [org.sw.demo.openexr.IlmImf-2.5.7]/OpenEXR/IlmImf/ImfMatrixAttribute.cpp
[24/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/bio/bss_acpt.c
[25/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/pem/pvkfmt.c
[28/3146] [org.sw.demo.google.brotli-1.0.9]/enc/cluster.c
[29/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/evp/pmeth_gn.c
[30/3146] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/ec/ec_oct.c
[31/3146] [org.sw.demo.c_ares-1.18.1]/src/lib/ares_free_hostent.c
[32/3146] [org.sw.demo.madler.zlib-1.2.12]/inffast.c
[33/3146] [org.sw.demo.malaterre.GDCM.jpeg16-3.0.14]/Utilities/gdcmjpeg/jcodec.c
[34/3146] [org.sw.demo.nghttp2-1.48.0]/lib/nghttp2_queue.c
[35/3146] [org.sw.demo.malaterre.GDCM.jpeg16-3.0.14]/Utilities/gdcmjpeg/jcpred.c
[36/3146] [org.sw.demo.malaterre.GDCM.gdcm-3.0.14]/Source/MediaStorageAndFileFormat/gdcmXMLPrinter.cxx
[37/3146] [org.sw.demo.jxl-0.6.1]/lib/jxl/enc_coeff_order.cc
[38/3146] [org.sw.demo.openexr.IlmImf-2.5.7]/OpenEXR/IlmImf/ImfFrameBuffer.cpp
[39/3146] [org.sw.demo.malaterre.GDCM.gdcm-3.0.14]/Source/Common/gdcmTrace.cxx
Exception in file D:\dev\cppan2\client2\src\sw\builder\command.cpp:840, function execute1: When executing: [ocr-0.0.1]/ocr.cpp
C:/Users/Ottunger/Desktop/dev/satoris-ocr/ocr.cpp:3:10: fatal error: 'opencv2/videoio.hpp' file not found
#include <opencv2/videoio.hpp>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
command failed: exit code = 1
Exception in file D:\dev\cppan2\client2\src\sw\builder\command.cpp:840, function execute1: When executing: [ocr-0.0.1]/process.cpp
In file included from C:/Users/Ottunger/Desktop/dev/satoris-ocr/process.cpp:3:
C:/Users/Ottunger/Desktop/dev/satoris-ocr/opencv_hough_lines.h:4:10: fatal error: 'opencv2/video.hpp' file not found
#include <opencv2/video.hpp>
         ^~~~~~~~~~~~~~~~~~~
1 error generated.
command failed: exit code = 1
Total errors: 2

Can't yet get it better, do not understand why it does not include the header files for libraries yet.

egorpugin commented 2 years ago

Add to sw.cpp

    ocr += "org.sw.demo.intel.opencv.imgcodecs"_dep;
    ocr += "org.sw.demo.intel.opencv.videoio"_dep;
    ocr += "org.sw.demo.google.tesseract.libtesseract"_dep;
Ottunger commented 2 years ago

Muuuuuch better!

Until:

[2060/4193] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/kdf/kdf_err.c
[2061/4193] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/poly1305/poly1305_ieee754.c
[2062/4193] [org.sw.demo.badger.curl.libcurl-7.84.0]/lib/nonblock.c
[2063/4193] [org.sw.demo.facebook.zstd.zstd-1.5.2]/lib/common/pool.c
[2064/4193] [org.sw.demo.webmproject.webp-1.1.0]/src/enc/predictor_enc.c
Exception in file D:\dev\cppan2\client2\src\sw\builder\command.cpp:840, function execute1: When executing: [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/poly1305/poly1305_ieee754.c
C:/Users/Ottunger/.sw/storage/pkg/03/19/b62d/src/sdir/crypto/poly1305/poly1305_ieee754.c:107:2: error: "unrecognized platform"
#error "unrecognized platform"
 ^
1 error generated.
command failed: exit code = 1
Total errors: 1

Guess that will need modifications in the library here though :( Can I see the path that made me import this lib? Strange to me to have poly1305 with OpenCV and Tesseract.

egorpugin commented 2 years ago

Now I do this.

1. image

  1. sw.cpp

    void build(Solution &s)
    {
    auto &ocr = s.addSharedLibrary("ocr");
    ocr += cpp17;
    ocr += "OCR_API"_api;
    ocr +=
        "opencv_hough_lines.cpp",
        "process.cpp",
        "TD1Builder.cpp",
        "ocr.cpp"
        ;
    ocr += "org.sw.demo.intel.opencv.imgcodecs"_dep;
    ocr += "org.sw.demo.intel.opencv.video"_dep;
    ocr += "org.sw.demo.intel.opencv.videoio"_dep;
    ocr += "org.sw.demo.google.tesseract.libtesseract"_dep;
    }
  2. sw build -settings-file win2android.json -sfc --print-checks -wait-for-cc-checks -static -sd

With it I see only linker error in the last command. But adding -static hides some errors which is not right.

You can go to .sw/rsp. Remove all filex except the newest two. Remove from .rsp file -pthread arg and you'll see:

>13785605742374176959.bat
[ocr-0.0.1].so
ld.lld: error: undefined symbol: tesseract::DotProductNEON(double const*, double const*, int)
>>> referenced by simddetect.cpp
>>>               simddetect.cpp.c41c9921.o:(tesseract::SIMDDetect::SIMDDetect()) in archive D:/dev/swst/pkg/83/53/fe1c/obj/bld/689501/lib/liborg.sw.demo.google.tesseract.libtesseract-5.2.0.a
>>> referenced by simddetect.cpp
>>>               simddetect.cpp.c41c9921.o:(tesseract::SIMDDetect::SIMDDetect()) in archive D:/dev/swst/pkg/83/53/fe1c/obj/bld/689501/lib/liborg.sw.demo.google.tesseract.libtesseract-5.2.0.a
>>> referenced by simddetect.cpp
>>>               simddetect.cpp.c41c9921.o:(tesseract::SIMDDetect::Update()) in archive D:/dev/swst/pkg/83/53/fe1c/obj/bld/689501/lib/liborg.sw.demo.google.tesseract.libtesseract-5.2.0.a
>>> referenced 1 more times

ld.lld: error: undefined symbol: __android_log_print
>>> referenced by logger.cpp
>>>               logger.cpp.fd1e2ed4.o:(cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LogLevel, char const*)) in archive D:/dev/swst/pkg/d5/85/e45b/obj/bld/689501/lib/liborg.sw.demo.intel.opencv.core-4.6.0.a
>>> referenced by system.cpp
>>>               system.cpp.3c4d8743.o:(cv::error(cv::Exception const&)) in archive D:/dev/swst/pkg/d5/85/e45b/obj/bld/689501/lib/liborg.sw.demo.intel.opencv.core-4.6.0.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

In short:

ld.lld: error: undefined symbol: tesseract::DotProductNEON(double const*, double const*, int)
ld.lld: error: undefined symbol: __android_log_print

One unresolved from tess (have to adjust it build script) and one from opencv.

Ottunger commented 2 years ago

Okay, you're better off than me, I'm surprised about my error then but I will try your command already.

Unfortunately, I don't have much clue in how SW chooses what to give to linker as input, to know why these two are not made available...

egorpugin commented 2 years ago

Those are just build script errors. I prepared them for main platforms at first. Again because of limited time. Android/IOS was not tested.

Ottunger commented 2 years ago

I bet, is normal to have priorities :)

Didn't manage to achieve same result with your command, I get an error of another undefined type still at compile time personally.

egorpugin commented 2 years ago

Seems I missed this change for you. Add arch in config.

    "os": {
        "kernel": "org.torvalds.linux",
        "version": "5.17",
        "arch": "aarch64"
    }
egorpugin commented 2 years ago

So I am able now to build this shared library. Add -llog after you see this error.

>13785605742374176959.bat
[ocr-0.0.1].so
ld.lld: error: undefined symbol: __android_log_print
>>> referenced by logger.cpp
>>>               logger.cpp.fd1e2ed4.o:(cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LogLevel, char const*)) in archive D:/dev/swst/pkg/d5/85/e45b/obj/bld/689501/lib/liborg.sw.demo.intel.opencv.core-4.6.0.a
>>> referenced by system.cpp
>>>               system.cpp.3c4d8743.o:(cv::error(cv::Exception const&)) in archive D:/dev/swst/pkg/d5/85/e45b/obj/bld/689501/lib/liborg.sw.demo.intel.opencv.core-4.6.0.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

After:

>13785605742374176959.bat -llog
[ocr-0.0.1].so
Ottunger commented 2 years ago

I managed to build the static lib libocr-0.0.1.a

Now should I try without the -static flag? This .bat file you run to finish the process, where do you get it from?

Also, does your build system set any variable to preprocessor? So that I can keep "ddlspec" in case of a CMake build?

Subsidiary question, how can I copy checks X to checks Y? Each time I modify the build command I must replay all the checks... I would like to say to go see for results of checks of the previous run.

egorpugin commented 2 years ago

This .bat file you run to finish the process, where do you get it from?

In .sw/rsp dir.

Also, does your build system set any variable to preprocessor? So that I can keep "ddlspec" in case of a CMake build?

You can try to left your code unchanged. I do not remember, maybe it was just a warning. If no, just add #ifndef OCR_API ... #endif.

Subsidiary question, how can I copy checks X to checks Y?

Copy checks.txt from prepared dir to new one which it asks for.

Ottunger commented 2 years ago

Cool thanks for the hints.

How did you build the .so? If I just take out the flag -static I end up with error:

[2743/4198] [org.sw.demo.openssl.crypto-1.1.1.14]/crypto/modes/ccm128.c
Exception in file D:\dev\cppan2\client2\src\sw\builder\command.cpp:840, function execute1: When executing: [org.sw.demo.sqlite3-3.39.0].so
ld.lld: error: unable to find library -lpthread
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
command failed: exit code = 1
command is copied to C:\Users\Ottunger\Desktop\dev\satoris-ocr\.sw\rsp\17243064304372016430.bat

Total errors: 1
egorpugin commented 2 years ago

Check out this post https://github.com/SoftwareNetwork/sw/issues/97#issuecomment-1194445529= and go to p.3.

Ottunger commented 2 years ago

Well this command works for me, but it generates the static lib, .a, and not the shared lib, .so. Hence I say, I tried to take out the -static, but no luck

egorpugin commented 2 years ago

Remove all files from rsp dir. Also re-check your sw.cpp, maybe you did not update it. Re-run.

Ottunger commented 2 years ago

That's my sw.cpp

void build(Solution &s)
{
    auto &ocr = s.addStaticLibrary("ocr");
    ocr += cpp17;
    ocr += "OCR_API"_api;
    ocr +=
            "opencv_hough_lines.cpp",
            "process.cpp",
            "TD1Builder.cpp",
            "ocr.cpp"
            ;
    ocr += "org.sw.demo.intel.opencv.imgcodecs"_dep;
    ocr += "org.sw.demo.intel.opencv.videoio"_dep;
    ocr += "org.sw.demo.intel.opencv.video"_dep;
    ocr += "org.sw.demo.google.tesseract.libtesseract"_dep;
}

And cleaning rsp does not help.

Just to be clear, to build the .so, you used command with or without -static?

egorpugin commented 2 years ago

Just to be clear, to build the .so, you used command with or without -static?

Without.

That's my sw.cpp

You still have outdated sw.cpp. I provide it full expecting you to copy it full, not adding lines. You do not see changes in line auto &ocr = s.addStaticLibrary("ocr"); (your outdated line, check mine).


Upd.: Actual line should be

auto &ocr = s.addSharedLibrary("ocr");

or even

auto &ocr = s.addLibrary("ocr");
egorpugin commented 2 years ago

I see. Probably you need

auto &ocr = s.addSharedLibrary("ocr");

and run command WITH -static.

Sorry for misleading.

Ottunger commented 2 years ago

Ah, I'm bad at copying because I try to understand x)

So, with your last comment I still get:

C:\Users\Ottunger\Desktop\dev\satoris-ocr>sw build -settings-file win2android.json -sfc --print-checks -wait-for-cc-checks -static -sd 
[4027/4198] [ocr-0.0.1]/process.cpp
[4053/4198] [ocr-0.0.1]/opencv_hough_lines.cpp
[4124/4198] [ocr-0.0.1]/TD1Builder.cpp
[4152/4198] [ocr-0.0.1]/ocr.cpp
[4198/4198] [ocr-0.0.1].so
Exception in file D:\dev\cppan2\client2\src\sw\builder\command.cpp:840, function execute1: When executing: [ocr-0.0.1].so
ld.lld: error: unable to find library -lpthread
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
command failed: exit code = 1
command is copied to C:\Users\Ottunger\Desktop\dev\satoris-ocr\.sw\rsp\8170883198169567397.bat
Ottunger commented 2 years ago

But let me try a clean build too

egorpugin commented 2 years ago

So, with your last comment I still get: (https://github.com/SoftwareNetwork/sw/issues/97#issuecomment-1194558085)

It is ok, it is current progress. Now go post https://github.com/SoftwareNetwork/sw/issues/97#issuecomment-1194445529 and go to p.3.

Ottunger commented 2 years ago

Okay gotcha now! I have the .so library too :)

Will be time for some testing in place, but for this, I need a JNI declaration! This is supposedly the role of OcrServiceJNI.cpp:

#include <jni.h>
#include "ocr.h"

extern "C"
JNIEXPORT jstring JNICALL
Java_lu_satoris_android_ocr_OcrService_ocr(JNIEnv *env, jobject, int video, int psmType=6) {
    char* result = ocr("data", false, nullptr, video, psmType, false);
    if(!result) return nullptr;
    return env->NewStringUTF(result);
}

But I guess I should use also some custom declaration here?