Skip to content

Cannot build on Apple M2 #7

Description

@lfoppiano

I tried to build this project on an Apple M1 and it seems that some bindings are missing.

Java build log
(base) ➜  cc git clone https://github.com/commoncrawl/language-detection-cld2.git
cd language-detection-cld2/
mvn install
Cloning into 'language-detection-cld2'...
remote: Enumerating objects: 199, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 199 (delta 9), reused 31 (delta 6), pack-reused 161 (from 1)
Receiving objects: 100% (199/199), 151.36 KiB | 437.00 KiB/s, done.
Resolving deltas: 100% (58/58), done.
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------< org.commoncrawl:language-detection-cld2 >---------------
[INFO] Building language-detection-cld2 0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/de/thetaphi/forbiddenapis/3.9/forbiddenapis-3.9.pom
Downloaded from central: https://repo.maven.apache.org/maven2/de/thetaphi/forbiddenapis/3.9/forbiddenapis-3.9.pom (2.9 kB at 6.2 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/de/thetaphi/forbiddenapis/3.9/forbiddenapis-3.9.jar
Downloaded from central: https://repo.maven.apache.org/maven2/de/thetaphi/forbiddenapis/3.9/forbiddenapis-3.9.jar (472 kB at 965 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.17.0/jna-5.17.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.17.0/jna-5.17.0.pom (2.0 kB at 17 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar (2.0 MB at 5.1 MB/s)
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ language-detection-cld2 ---
[INFO] skip non existing resourceDirectory /Users/lfoppiano/development/projects/cc/language-detection-cld2/src/main/resources
[INFO] 
[INFO] --- compiler:3.14.1:compile (default-compile) @ language-detection-cld2 ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 7 source files with javac [debug target 1.8] to target/classes
[WARNING] bootstrap class path not set in conjunction with -source 8
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ language-detection-cld2 ---
[INFO] Copying 2 resources from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.14.1:testCompile (default-testCompile) @ language-detection-cld2 ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 2 source files with javac [debug target 1.8] to target/test-classes
[WARNING] bootstrap class path not set in conjunction with -source 8
[INFO] 
[INFO] --- surefire:3.5.4:test (default-test) @ language-detection-cld2 ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.commoncrawl.langdetect.cld2.DetectionTest
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.445 s <<< FAILURE! -- in org.commoncrawl.langdetect.cld2.DetectionTest
[ERROR] org.commoncrawl.langdetect.cld2.DetectionTest.testPlainText -- Time elapsed: 0.420 s <<< ERROR!
java.lang.UnsatisfiedLinkError: 
Unable to load library 'cld2':
dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)
dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)
dlopen(/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file)
dlopen(/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/cld2.framework/cld2' (no such file), '/Library/Frameworks/cld2.framework/cld2' (no such file)
dlopen(/System/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Library/Frameworks/cld2.framework/cld2' (no such file, not in dyld cache)
Native library (darwin-aarch64/libcld2.dylib) not found in resource path (/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/test-classes:/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/classes:/Users/lfoppiano/.m2/repository/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar:/Users/lfoppiano/.m2/repository/org/slf4j/slf4j-api/2.0.17/slf4j-api-2.0.17.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.13.4/junit-jupiter-api-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-commons/1.13.4/junit-platform-commons-1.13.4.jar:/Users/lfoppiano/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.13.4/junit-jupiter-engine-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-engine/1.13.4/junit-platform-engine-1.13.4.jar:)
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:325)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:481)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:423)
        at org.commoncrawl.langdetect.cld2.Cld2Library.<clinit>(Cld2Library.java:33)
        at org.commoncrawl.langdetect.cld2.Cld2.getLanguageFromName(Cld2.java:27)
        at org.commoncrawl.langdetect.cld2.Language.<clinit>(Language.java:670)
        at org.commoncrawl.langdetect.cld2.CLDHints.<clinit>(CLDHints.java:63)
        at org.commoncrawl.langdetect.cld2.Cld2.detect(Cld2.java:82)
        at org.commoncrawl.langdetect.cld2.Cld2.detect(Cld2.java:69)
        at org.commoncrawl.langdetect.cld2.DetectionTest.run(DetectionTest.java:49)
        at org.commoncrawl.langdetect.cld2.DetectionTest.testPlainText(DetectionTest.java:60)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        Suppressed: java.lang.UnsatisfiedLinkError: dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)
                at com.sun.jna.Native.open(Native Method)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:213)
                ... 13 more
        Suppressed: java.lang.UnsatisfiedLinkError: dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)
                at com.sun.jna.Native.open(Native Method)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:226)
                ... 13 more
        Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file)
                at com.sun.jna.Native.open(Native Method)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:270)
                ... 13 more
        Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/cld2.framework/cld2' (no such file), '/Library/Frameworks/cld2.framework/cld2' (no such file)
                at com.sun.jna.Native.open(Native Method)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:270)
                ... 13 more
        Suppressed: java.lang.UnsatisfiedLinkError: dlopen(/System/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Library/Frameworks/cld2.framework/cld2' (no such file, not in dyld cache)
                at com.sun.jna.Native.open(Native Method)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:270)
                ... 13 more
        Suppressed: java.io.IOException: Native library (darwin-aarch64/libcld2.dylib) not found in resource path (/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/test-classes:/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/classes:/Users/lfoppiano/.m2/repository/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar:/Users/lfoppiano/.m2/repository/org/slf4j/slf4j-api/2.0.17/slf4j-api-2.0.17.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.13.4/junit-jupiter-api-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-commons/1.13.4/junit-platform-commons-1.13.4.jar:/Users/lfoppiano/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.13.4/junit-jupiter-engine-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-engine/1.13.4/junit-platform-engine-1.13.4.jar:)
                at com.sun.jna.Native.extractFromResourcePath(Native.java:1141)
                at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:297)
                ... 13 more

[ERROR] org.commoncrawl.langdetect.cld2.DetectionTest.testHtml -- Time elapsed: 0.002 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints
        at org.commoncrawl.langdetect.cld2.Cld2.detect(Cld2.java:90)
        at org.commoncrawl.langdetect.cld2.DetectionTest.lambda$testHtml$2(DetectionTest.java:73)
        at org.commoncrawl.langdetect.cld2.DetectionTest.run(DetectionTest.java:49)
        at org.commoncrawl.langdetect.cld2.DetectionTest.testHtml(DetectionTest.java:72)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

[ERROR] org.commoncrawl.langdetect.cld2.DetectionTest.testContentLanguageHint -- Time elapsed: 0.001 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints
        at org.commoncrawl.langdetect.cld2.DetectionTest.testContentLanguageHint(DetectionTest.java:82)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

[INFO] Running org.commoncrawl.langdetect.cld2.EncodingTest
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.005 s <<< FAILURE! -- in org.commoncrawl.langdetect.cld2.EncodingTest
[ERROR] org.commoncrawl.langdetect.cld2.EncodingTest.testEncodingHint -- Time elapsed: 0 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints
        at org.commoncrawl.langdetect.cld2.EncodingTest.testEncodingHint(EncodingTest.java:52)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   DetectionTest.testContentLanguageHint:82 NoClassDefFound Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints
[ERROR]   DetectionTest.testHtml:72->run:49->lambda$testHtml$2:73 » NoClassDefFound Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints                                                                                                                                                   
[ERROR]   DetectionTest.testPlainText:60->run:49 » UnsatisfiedLink Unable to load library 'cld2':
dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)                                                                                                             
dlopen(libcld2.dylib, 0x0009): tried: 'libcld2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcld2.dylib' (no such file), '/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/../lib/jli/libcld2.dylib' (no such file), '/usr/lib/libcld2.dylib' (no such file, not in dyld cache), 'libcld2.dylib' (no such file)                                                                                                             
dlopen(/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file), '/Users/lfoppiano/Library/Frameworks/cld2.framework/cld2' (no such file)                                                                                                               
dlopen(/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/cld2.framework/cld2' (no such file), '/Library/Frameworks/cld2.framework/cld2' (no such file)                          
dlopen(/System/Library/Frameworks/cld2.framework/cld2, 0x0009): tried: '/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Library/Frameworks/cld2.framework/cld2' (no such file), '/System/Library/Frameworks/cld2.framework/cld2' (no such file, not in dyld cache)                                                                                                                                
Native library (darwin-aarch64/libcld2.dylib) not found in resource path (/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/test-classes:/Users/lfoppiano/development/projects/cc/language-detection-cld2/target/classes:/Users/lfoppiano/.m2/repository/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar:/Users/lfoppiano/.m2/repository/org/slf4j/slf4j-api/2.0.17/slf4j-api-2.0.17.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.13.4/junit-jupiter-api-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-commons/1.13.4/junit-platform-commons-1.13.4.jar:/Users/lfoppiano/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/lfoppiano/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.13.4/junit-jupiter-engine-5.13.4.jar:/Users/lfoppiano/.m2/repository/org/junit/platform/junit-platform-engine/1.13.4/junit-platform-engine-1.13.4.jar:)                         
[ERROR]   EncodingTest.testEncodingHint:52 NoClassDefFound Could not initialize class org.commoncrawl.langdetect.cld2.CLDHints
[INFO] 
[ERROR] Tests run: 6, Failures: 0, Errors: 4, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.558 s
[INFO] Finished at: 2026-02-23T18:14:21+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.4:test (default-test) on project language-detection-cld2: 
[ERROR] 
[ERROR] See /Users/lfoppiano/development/projects/cc/language-detection-cld2/target/surefire-reports for the individual test results.
[ERROR] See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

The issue is due to the cld2 library:

git clone https://github.com/CLD2Owners/cld2.git
cd cld/internal/ <- typo, it should be cld2
export CFLAGS="-Wno-narrowing -O3"
./compile_and_test_all.sh

but also failed on Apple M1

Opened an issue here CLD2Owners/cld2#71

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions