Skip to content

Linking error #101

Description

@Blayung
...
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13c8) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13d0) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13d8) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13e0) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13e8) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x13f0) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x1400) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: ld.lld: relocation R_AARCH64_ABS64 cannot be used against local symbol; recompile with -fPIC
    note: defined in .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a(.zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o)
    note: referenced by rcore.c
    note:               .zig-cache/o/b173216c63e5989c3ae946e46e63970e/rcore.o:(.rodata+0x1420) in archive .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a
error: 841 compilation errors
failed command: /usr/bin/zig build-lib -fllvm -flld .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a -landroid /home/wojtek/apps/android-sdk/ndk/29.0.13113456/sources/android/native_app_glue/android_native_app_glue.c /home/wojtek/programming/game/src/save/android_internal_data_path.c -fstrip -OReleaseSmall -target aarch64-linux-android -mcpu baseline+v8a -I .zig-cache/o/0cb472c14c1ac56695fea882facb905b -I /home/wojtek/apps/android-sdk/ndk/29.0.13113456/sources/android/native_app_glue -L /home/wojtek/apps/android-sdk/ndk/29.0.13113456/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/35 -L /home/wojtek/apps/android-sdk/ndk/29.0.13113456/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android --dep raylib --dep android -Mroot=/home/wojtek/programming/game/src/main.zig .zig-cache/o/a6596e2ec12410ba0b859ffa55563dc1/libraylib.a -OReleaseSmall -target aarch64-linux-android -mcpu baseline+v8a -I .zig-cache/o/0cb472c14c1ac56695fea882facb905b -Mraylib=/home/wojtek/programming/game/zig-pkg/raylib_zig-6.0.0-KE8REMNkBQCpxwqT9ubVNf5aEOcWRUVIaH2sgt_sDDoZ/lib/raylib.zig -llog -OReleaseSmall -target aarch64-linux-android -mcpu baseline+v8a --dep ndk --dep android_builtin --dep zig016 -Mandroid=/home/wojtek/programming/game/zig-pkg/android-0.3.0-7iz7QkgyAgCCCsGXARq_j2DYLmIZoVlDh5ugZUUhKxAQ/src/android/android.zig -OReleaseSmall -target aarch64-linux-android -mcpu baseline+v8a -Mndk=/home/wojtek/programming/game/zig-pkg/android-0.3.0-7iz7QkgyAgCCCsGXARq_j2DYLmIZoVlDh5ugZUUhKxAQ/src/android/ndk/ndk.zig -Mandroid_builtin=.zig-cache/c/b1e5468ce6edd281b237a76e1dccba1e/options.zig -OReleaseSmall -target aarch64-linux-android -mcpu baseline+v8a --dep ndk --dep android_builtin -Mzig016=/home/wojtek/programming/game/zig-pkg/android-0.3.0-7iz7QkgyAgCCCsGXARq_j2DYLmIZoVlDh5ugZUUhKxAQ/src/android/zig016/zig016.zig -lEGL -lGLESv2 -lc -z max-page-size=16384 --libc .zig-cache/o/0f5f572e30d9985f9766575f03e00811/android-libc_target-aarch64-linux-android_version-35_ndk-29.0.13113456.conf --cache-dir .zig-cache --global-cache-dir /home/wojtek/.cache/zig --name game -dynamic -fcompiler-rt --zig-lib-dir /usr/lib/zig/ --listen=-

Build Summary: 35/45 steps succeeded (3 failed)
install transitive failure
└─ install generated to game.apk transitive failure
   └─ zig-android-sdk apksigner transitive failure
      └─ zig-android-sdk zipalign transitive failure
         ├─ zig-android-sdk jar (zip compress apk) transitive failure
         │  ├─ WriteFile lib/x86/libgame.so transitive failure
         │  │  ├─ compile lib game ReleaseSmall x86_64-linux-android 4129 errors
         │  │  ├─ compile lib game ReleaseSmall aarch64-linux-android 841 errors
         │  │  └─ compile lib game ReleaseSmall arm-linux-androideabi 6041 errors
         │  └─ WriteFile lib/x86/libgame.so (+6 more reused dependencies)
         └─ zig-android-sdk jar (update zip with uncompressed files) transitive failure
            └─ zig-android-sdk jar (zip compress apk) (+2 more reused dependencies)

error: the following build command failed with exit code 1:
.zig-cache/o/05199023dc3877ba513c8ca35a357e87/build /usr/bin/zig /usr/lib/zig /home/wojtek/programming/game .zig-cache /home/wojtek/.cache/zig --seed 0xe9e094b2 -Za493c53c305eb85f -Dandroid -Doptimize=ReleaseSmall

build.zig:

    if (android_targets.len > 0) {
        const apk = android.Sdk.create(b, .{}).createApk(.{
            .name = app_name,
            .api_level = .android15,
            .build_tools_version = "35.0.1",
            .ndk_version = "29.0.13113456"
        });

        apk.setAndroidManifest(b.path("android/AndroidManifest.xml"));

        const app_id = "me.teamaster." ++ app_name;

        apk.setKeyStore(apk.sdk.createKeyStore(if (optimize == .Debug) .example else .{
            .alias = "release",
            .password = b.graph.environ_map.get("ANDROID_KEYSTORE_PSWRD") orelse @panic("ANDROID_KEYSTORE_PSWRD is undefined!"),
            .algorithm = .rsa,
            .key_size_in_bits = 4096,
            .validity_in_days = 36500,
            .distinguished_name = "CN=" ++ app_id ++ ", C=PL"
        }));

        apk.addResourceDirectory(b.path("android/resources"));
        apk.addAssetDirectory(b.path("assets"));

        for (android_targets) |android_target| {
            const module = b.createModule(.{
                .root_source_file = b.path("src/main.zig"),
                .target = android_target,
                .optimize = optimize
            });

            const lib = b.addLibrary(.{
                .linkage = .dynamic,
                .name = app_name,
                .root_module = module,
                //.use_llvm = true
            });

            const raylib_dep = b.dependency("raylib_zig", .{
                .target = android_target,
                .optimize = optimize,
                .platform = .android,
                .opengl_version = raylib_zig.OpenglVersion.gles_2,
                .android_api_version = @as([]const u8, b.fmt("{d}", .{ @intFromEnum(apk.api_level) })),
                .android_ndk = @as([]const u8, apk.ndk.path)
            });

            module.addImport("raylib", raylib_dep.module("raylib"));
            module.linkLibrary(raylib_dep.artifact("raylib"));

            const android_dep = b.dependency("android", .{
                .target = android_target,
                .optimize = optimize
            });

            module.addImport("android", android_dep.module("android"));
            module.linkSystemLibrary("android", .{});

            //module.linkSystemLibrary("GLESv2", .{});
            //module.linkSystemLibrary("EGL", .{});

            const native_app_glue_dir = std.Build.LazyPath { .cwd_relative = b.pathJoin(&.{ apk.ndk.path, "sources/android/native_app_glue" }) };
            module.addIncludePath(native_app_glue_dir);
            module.addCSourceFile(.{ .file = native_app_glue_dir.path(b, "android_native_app_glue.c") });
            module.addCSourceFile(.{ .file = b.path("src/save/android_internal_data_path.c") });

            apk.addArtifact(lib);
        }

        const installed_apk = apk.addInstallApk();
        b.getInstallStep().dependOn(&installed_apk.step);

        const adb_install = apk.sdk.addAdbInstall(installed_apk.source);
        const adb_start = apk.sdk.addAdbStart(app_id ++ "/android.app.NativeActivity");
        adb_start.step.dependOn(&adb_install.step);
        run_step.dependOn(&adb_start.step);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions