HarmonyOS 鸿蒙Next编译适配opus静态库问题

发布于 1周前 作者 phonegap100 来自 鸿蒙OS

HarmonyOS 鸿蒙Next编译适配opus静态库问题

我在编译适配鸿蒙的动态库是需要依赖opus静态库,在ubantu上编译opus 1.3.1 静态库时出现一下问题
这是我的编译命令

CC=/usr/ohos-sdk/ohos-sdk/linux/native/llvm/bin/clang CFLAGS="–target=aarch64-linux-ohos -fPIC --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot" LDFLAGS="–target=aarch64-linux-ohos -fPIC --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot" LD=/usr/ohos-sdk/ohos-sdk/linux/native/llvm/bin/ld.lld ./configure --host=arm-linux --enable-static --prefix=$(pwd)/my_build
make V=1
编译后出现
cke_7114.png

这样的问题,有没有大佬能提供一下解决思路
我也有编译脚本
如下

export OHOS_TOOLCHAIN=/usr/ohos-sdk/ohos-sdk/linux/native/llvm

export OHOS_SYSROOT=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot

export CC=${OHOS_TOOLCHAIN}/bin/clang

export CPP=${OHOS_TOOLCHAIN}/bin/clang++

export AR=${OHOS_TOOLCHAIN}/bin/llvm-ar

export AS=${OHOS_TOOLCHAIN}/bin/llvm-as

export NM=${OHOS_TOOLCHAIN}/bin/llvm-nm

export STRIP=${OHOS_TOOLCHAIN}/bin/llvm-strip

export RANLIB=${OHOS_TOOLCHAIN}/bin/llvm-ranlib

export LD="${OHOS_TOOLCHAIN}/bin/lld --target=arm-linux-ohos"

export LDFLAGS="-fuse-ld=lld"

export CFLAGS="-fPIC --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp"

export CPPFLAGS="-fPIC --target=arm-linux-ohos --sysroot=${OHOS_SYSROOT} -march=armv7-a -mfloat-abi=softfp"

./configure --host=arm-linux </p>

    --prefix=$(pwd)/my_build </p>

    --enable-static

make clean

make -j4

5 回复
我看了下opus基本上openssl差不多,可以参考下 https://github.com/ohos-rs/ohos-openssl

我看看感谢

楼主搞定了吗?

/bin/bash ./libtool  --tag=CC   --mode=link /usr/ohos-sdk/ohos-sdk/linux/native/llvm/bin/clang  --target=aarch64-linux-ohos -fPIC --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot -fvisibility=hidden -D_FORTIFY_SOURCE=2 -W -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -no-undefined -version-info 8:0:8 --target=aarch64-linux-ohos --target=aarch64-linux-ohos -fPIC --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot -o libopus.la -rpath /data/duan/better_sdk/opus/third/opus-1.3.1/opus-1.3.1/ohos/lib celt/bands.lo celt/celt.lo celt/celt_encoder.lo celt/celt_decoder.lo celt/cwrs.lo celt/entcode.lo celt/entdec.lo celt/entenc.lo celt/kiss_fft.lo celt/laplace.lo celt/mathops.lo celt/mdct.lo celt/modes.lo celt/pitch.lo celt/celt_lpc.lo celt/quant_bands.lo celt/rate.lo celt/vq.lo    celt/arm/armcpu.lo celt/arm/arm_celt_map.lo celt/arm/celt_neon_intr.lo celt/arm/pitch_neon_intr.lo  silk/CNG.lo silk/code_signs.lo silk/init_decoder.lo silk/decode_core.lo silk/decode_frame.lo silk/decode_parameters.lo silk/decode_indices.lo silk/decode_pulses.lo silk/decoder_set_fs.lo silk/dec_API.lo silk/enc_API.lo silk/encode_indices.lo silk/encode_pulses.lo silk/gain_quant.lo silk/interpolate.lo silk/LP_variable_cutoff.lo silk/NLSF_decode.lo silk/NSQ.lo silk/NSQ_del_dec.lo silk/PLC.lo silk/shell_coder.lo silk/tables_gain.lo silk/tables_LTP.lo silk/tables_NLSF_CB_NB_MB.lo silk/tables_NLSF_CB_WB.lo silk/tables_other.lo silk/tables_pitch_lag.lo silk/tables_pulses_per_block.lo silk/VAD.lo silk/control_audio_bandwidth.lo silk/quant_LTP_gains.lo silk/VQ_WMat_EC.lo silk/HP_variable_cutoff.lo silk/NLSF_encode.lo silk/NLSF_VQ.lo silk/NLSF_unpack.lo silk/NLSF_del_dec_quant.lo silk/process_NLSFs.lo silk/stereo_LR_to_MS.lo silk/stereo_MS_to_LR.lo silk/check_control_input.lo silk/control_SNR.lo silk/init_encoder.lo silk/control_codec.lo silk/A2NLSF.lo silk/ana_filt_bank_1.lo silk/biquad_alt.lo silk/bwexpander_32.lo silk/bwexpander.lo silk/debug.lo silk/decode_pitch.lo silk/inner_prod_aligned.lo silk/lin2log.lo silk/log2lin.lo silk/LPC_analysis_filter.lo silk/LPC_inv_pred_gain.lo silk/table_LSF_cos.lo silk/NLSF2A.lo silk/NLSF_stabilize.lo silk/NLSF_VQ_weights_laroia.lo silk/pitch_est_tables.lo silk/resampler.lo silk/resampler_down2_3.lo silk/resampler_down2.lo silk/resampler_private_AR2.lo silk/resampler_private_down_FIR.lo silk/resampler_private_IIR_FIR.lo silk/resampler_private_up2_HQ.lo silk/resampler_rom.lo silk/sigm_Q15.lo silk/sort.lo silk/sum_sqr_shift.lo silk/stereo_decode_pred.lo silk/stereo_encode_pred.lo silk/stereo_find_predictor.lo silk/stereo_quant_pred.lo silk/LPC_fit.lo    silk/float/apply_sine_window_FLP.lo silk/float/corrMatrix_FLP.lo silk/float/encode_frame_FLP.lo silk/float/find_LPC_FLP.lo silk/float/find_LTP_FLP.lo silk/float/find_pitch_lags_FLP.lo silk/float/find_pred_coefs_FLP.lo silk/float/LPC_analysis_filter_FLP.lo silk/float/LTP_analysis_filter_FLP.lo silk/float/LTP_scale_ctrl_FLP.lo silk/float/noise_shape_analysis_FLP.lo silk/float/process_gains_FLP.lo silk/float/regularize_correlations_FLP.lo silk/float/residual_energy_FLP.lo silk/float/warped_autocorrelation_FLP.lo silk/float/wrappers_FLP.lo silk/float/autocorrelation_FLP.lo silk/float/burg_modified_FLP.lo silk/float/bwexpander_FLP.lo silk/float/energy_FLP.lo silk/float/inner_product_FLP.lo silk/float/k2a_FLP.lo silk/float/LPC_inv_pred_gain_FLP.lo silk/float/pitch_analysis_core_FLP.lo silk/float/scale_copy_vector_FLP.lo silk/float/scale_vector_FLP.lo silk/float/schur_FLP.lo silk/float/sort_FLP.lo   silk/arm/arm_silk_map.lo silk/arm/biquad_alt_neon_intr.lo silk/arm/LPC_inv_pred_gain_neon_intr.lo silk/arm/NSQ_del_dec_neon_intr.lo silk/arm/NSQ_neon.lo src/opus.lo src/opus_decoder.lo src/opus_encoder.lo src/opus_multistream.lo src/opus_multistream_encoder.lo src/opus_multistream_decoder.lo src/repacketizer.lo src/opus_projection_encoder.lo src/opus_projection_decoder.lo src/mapping_matrix.lo src/analysis.lo src/mlp.lo src/mlp_data.lo  -lm  

libtool: link: /usr/ohos-sdk/ohos-sdk/linux/native/llvm/bin/clang -shared  -fPIC -DPIC  celt/.libs/bands.o celt/.libs/celt.o celt/.libs/celt_encoder.o celt/.libs/celt_decoder.o celt/.libs/cwrs.o celt/.libs/entcode.o celt/.libs/entdec.o celt/.libs/entenc.o celt/.libs/kiss_fft.o celt/.libs/laplace.o celt/.libs/mathops.o celt/.libs/mdct.o celt/.libs/modes.o celt/.libs/pitch.o celt/.libs/celt_lpc.o celt/.libs/quant_bands.o celt/.libs/rate.o celt/.libs/vq.o celt/arm/.libs/armcpu.o celt/arm/.libs/arm_celt_map.o celt/arm/.libs/celt_neon_intr.o celt/arm/.libs/pitch_neon_intr.o silk/.libs/CNG.o silk/.libs/code_signs.o silk/.libs/init_decoder.o silk/.libs/decode_core.o silk/.libs/decode_frame.o silk/.libs/decode_parameters.o silk/.libs/decode_indices.o silk/.libs/decode_pulses.o silk/.libs/decoder_set_fs.o silk/.libs/dec_API.o silk/.libs/enc_API.o silk/.libs/encode_indices.o silk/.libs/encode_pulses.o silk/.libs/gain_quant.o silk/.libs/interpolate.o silk/.libs/LP_variable_cutoff.o silk/.libs/NLSF_decode.o silk/.libs/NSQ.o silk/.libs/NSQ_del_dec.o silk/.libs/PLC.o silk/.libs/shell_coder.o silk/.libs/tables_gain.o silk/.libs/tables_LTP.o silk/.libs/tables_NLSF_CB_NB_MB.o silk/.libs/tables_NLSF_CB_WB.o silk/.libs/tables_other.o silk/.libs/tables_pitch_lag.o silk/.libs/tables_pulses_per_block.o silk/.libs/VAD.o silk/.libs/control_audio_bandwidth.o silk/.libs/quant_LTP_gains.o silk/.libs/VQ_WMat_EC.o silk/.libs/HP_variable_cutoff.o silk/.libs/NLSF_encode.o silk/.libs/NLSF_VQ.o silk/.libs/NLSF_unpack.o silk/.libs/NLSF_del_dec_quant.o silk/.libs/process_NLSFs.o silk/.libs/stereo_LR_to_MS.o silk/.libs/stereo_MS_to_LR.o silk/.libs/check_control_input.o silk/.libs/control_SNR.o silk/.libs/init_encoder.o silk/.libs/control_codec.o silk/.libs/A2NLSF.o silk/.libs/ana_filt_bank_1.o silk/.libs/biquad_alt.o silk/.libs/bwexpander_32.o silk/.libs/bwexpander.o silk/.libs/debug.o silk/.libs/decode_pitch.o silk/.libs/inner_prod_aligned.o silk/.libs/lin2log.o silk/.libs/log2lin.o silk/.libs/LPC_analysis_filter.o silk/.libs/LPC_inv_pred_gain.o silk/.libs/table_LSF_cos.o silk/.libs/NLSF2A.o silk/.libs/NLSF_stabilize.o silk/.libs/NLSF_VQ_weights_laroia.o silk/.libs/pitch_est_tables.o silk/.libs/resampler.o silk/.libs/resampler_down2_3.o silk/.libs/resampler_down2.o silk/.libs/resampler_private_AR2.o silk/.libs/resampler_private_down_FIR.o silk/.libs/resampler_private_IIR_FIR.o silk/.libs/resampler_private_up2_HQ.o silk/.libs/resampler_rom.o silk/.libs/sigm_Q15.o silk/.libs/sort.o silk/.libs/sum_sqr_shift.o silk/.libs/stereo_decode_pred.o silk/.libs/stereo_encode_pred.o silk/.libs/stereo_find_predictor.o silk/.libs/stereo_quant_pred.o silk/.libs/LPC_fit.o silk/float/.libs/apply_sine_window_FLP.o silk/float/.libs/corrMatrix_FLP.o silk/float/.libs/encode_frame_FLP.o silk/float/.libs/find_LPC_FLP.o silk/float/.libs/find_LTP_FLP.o silk/float/.libs/find_pitch_lags_FLP.o silk/float/.libs/find_pred_coefs_FLP.o silk/float/.libs/LPC_analysis_filter_FLP.o silk/float/.libs/LTP_analysis_filter_FLP.o silk/float/.libs/LTP_scale_ctrl_FLP.o silk/float/.libs/noise_shape_analysis_FLP.o silk/float/.libs/process_gains_FLP.o silk/float/.libs/regularize_correlations_FLP.o silk/float/.libs/residual_energy_FLP.o silk/float/.libs/warped_autocorrelation_FLP.o silk/float/.libs/wrappers_FLP.o silk/float/.libs/autocorrelation_FLP.o silk/float/.libs/burg_modified_FLP.o silk/float/.libs/bwexpander_FLP.o silk/float/.libs/energy_FLP.o silk/float/.libs/inner_product_FLP.o silk/float/.libs/k2a_FLP.o silk/float/.libs/LPC_inv_pred_gain_FLP.o silk/float/.libs/pitch_analysis_core_FLP.o silk/float/.libs/scale_copy_vector_FLP.o silk/float/.libs/scale_vector_FLP.o silk/float/.libs/schur_FLP.o silk/float/.libs/sort_FLP.o silk/arm/.libs/arm_silk_map.o silk/arm/.libs/biquad_alt_neon_intr.o silk/arm/.libs/LPC_inv_pred_gain_neon_intr.o silk/arm/.libs/NSQ_del_dec_neon_intr.o silk/arm/.libs/NSQ_neon.o src/.libs/opus.o src/.libs/opus_decoder.o src/.libs/opus_encoder.o src/.libs/opus_multistream.o src/.libs/opus_multistream_encoder.o src/.libs/opus_multistream_decoder.o src/.libs/repacketizer.o src/.libs/opus_projection_encoder.o src/.libs/opus_projection_decoder.o src/.libs/mapping_matrix.o src/.libs/analysis.o src/.libs/mlp.o src/.libs/mlp_data.o   -lm  --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot --sysroot=/usr/ohos-sdk/ohos-sdk/linux/native/sysroot   -Wl,-soname -Wl,libopus.so.0 -o .libs/libopus.so.0.8.0
这是make V=1最后出问题的巨长命令

针对HarmonyOS 鸿蒙Next编译适配opus静态库的问题,以下是一些可能的解决方案:

首先,确保你的编译环境已经正确配置。鸿蒙系统的编译环境需要特定的工具链和系统根目录,这些通常在鸿蒙SDK中提供。你需要确保这些路径在你的编译命令中正确设置。

其次,检查opus的configure脚本和Makefile文件,确保它们能够识别鸿蒙系统的目标架构和编译器。你可能需要手动编辑这些文件,以添加对鸿蒙系统的支持。

最后,尝试使用cmake等现代构建工具来编译opus,这可以简化编译过程并减少手动配置的错误。如果cmake支持鸿蒙系统,你可以创建一个CMakeLists.txt文件,并配置相应的编译选项和目标架构。

请注意,编译适配鸿蒙系统的opus静态库可能需要一些尝试和错误修正。如果上述方法无法解决问题,建议查阅鸿蒙系统的官方文档或社区论坛,以获取更具体的帮助。如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部