PCRE2Project / pcre2

PCRE2 development is now based here.
Other
921 stars 194 forks source link

ld.lld: error: undefined symbol: _pcre2_default_tables_8 #375

Closed pommeJack closed 10 months ago

pommeJack commented 10 months ago

I attempted to compile the 32-bit pcre2 library for an ARM architecture Linux system using cmake and clang, without making other configurations to the cmake script, and encountered the following errors:

[OHOS ERROR] [32/37] LINK common/common/pcre2posix_test
[OHOS ERROR] FAILED: common/common/pcre2posix_test exe.unstripped/common/common/pcre2posix_test 
[OHOS ERROR] /usr/bin/env "../../build/toolchain/gcc_link_wrapper.py" --output="common/common/pcre2posix_test" --strip="../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip" --unstripped-file="./exe.unstripped/common/common/pcre2posix_test"  --mini-debug -- ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++ -Wl,--pack-dyn-relocs=android+relr -Wl,--fatal-warnings -Wl,--build-id=md5 -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -Wl,--no-undefined -Wl,--exclude-libs=libunwind_llvm.a -Wl,--exclude-libs=libc++_static.a -Wl,--exclude-libs=libvpx_assembly_arm.a --target=arm-linux-ohos -Werror -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,--gdb-index --sysroot=obj/third_party/musl -nostdlib -Lobj/third_party/musl/usr/lib/arm-linux-ohos -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib/arm-linux-ohos -Wl,--warn-shared-textrel -Bdynamic -Wl,-z,nocopyreloc -pie -o "./exe.unstripped/common/common/pcre2posix_test" obj/third_party/musl/usr/lib/arm-linux-ohos/Scrt1.o obj/third_party/musl/usr/lib/arm-linux-ohos/crti.o -Wl,--start-group  @"common/common/pcre2posix_test.rsp"  -lunwind -lc++ ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib/arm-linux-ohos/libclang_rt.builtins.a -lc -lc++abi -ldl -lm -Wl,--end-group  obj/third_party/musl/usr/lib/arm-linux-ohos/crtn.o
[OHOS ERROR] ld.lld: error: undefined symbol: _pcre2_default_tables_8
[OHOS ERROR] >>> referenced by pcre2_context.c
[OHOS ERROR] >>>               pcre2_context.o:(_pcre2_default_compile_context_8) in archive obj/third_party/pcre2-pcre2-10.42/libpcre2-8-static.a
[OHOS ERROR] >>> referenced by pcre2_compile.c:0 (../../third_party/pcre2-pcre2-10.42/src/pcre2_compile.c:0)
[OHOS ERROR] >>>               pcre2_compile.o:(pcre2_compile_8) in archive obj/third_party/pcre2-pcre2-10.42/libpcre2-8-static.a
[OHOS ERROR] clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
[OHOS ERROR] [33/37] LINK common/common/pcre2grep
[OHOS ERROR] FAILED: common/common/pcre2grep exe.unstripped/common/common/pcre2grep 
[OHOS ERROR] /usr/bin/env "../../build/toolchain/gcc_link_wrapper.py" --output="common/common/pcre2grep" --strip="../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip" --unstripped-file="./exe.unstripped/common/common/pcre2grep"  --mini-debug -- ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++ -Wl,--pack-dyn-relocs=android+relr -Wl,--fatal-warnings -Wl,--build-id=md5 -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -Wl,--no-undefined -Wl,--exclude-libs=libunwind_llvm.a -Wl,--exclude-libs=libc++_static.a -Wl,--exclude-libs=libvpx_assembly_arm.a --target=arm-linux-ohos -Werror -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,--gdb-index --sysroot=obj/third_party/musl -nostdlib -Lobj/third_party/musl/usr/lib/arm-linux-ohos -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib/arm-linux-ohos -Wl,--warn-shared-textrel -Bdynamic -Wl,-z,nocopyreloc -pie -o "./exe.unstripped/common/common/pcre2grep" obj/third_party/musl/usr/lib/arm-linux-ohos/Scrt1.o obj/third_party/musl/usr/lib/arm-linux-ohos/crti.o -Wl,--start-group  @"common/common/pcre2grep.rsp"  -lunwind -lc++ ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib/arm-linux-ohos/libclang_rt.builtins.a -lc -lc++abi -ldl -lm -Wl,--end-group  obj/third_party/musl/usr/lib/arm-linux-ohos/crtn.o
[OHOS ERROR] ld.lld: error: undefined symbol: _pcre2_default_tables_8
[OHOS ERROR] >>> referenced by pcre2_context.c
[OHOS ERROR] >>>               pcre2_context.o:(_pcre2_default_compile_context_8) in archive obj/third_party/pcre2-pcre2-10.42/libpcre2-8-static.a
[OHOS ERROR] >>> referenced by pcre2_compile.c:0 (../../third_party/pcre2-pcre2-10.42/src/pcre2_compile.c:0)
[OHOS ERROR] >>>               pcre2_compile.o:(pcre2_compile_8) in archive obj/third_party/pcre2-pcre2-10.42/libpcre2-8-static.a
[OHOS ERROR] clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

Does anyone know why this might be happening?

carenas commented 10 months ago

can you show the command line / env values you used?

is it a "release" tarfile what you used or git? if the former was it 10.43RC1 and if hot could you try that?

also make sure you invoke cmake with the right toolset, it looks you were using a x86_64 crosscompiler by the output of your error.