Xavier(6):ubuntu18.04安装casadi 报错与解决(recompile with -fPIC)

报错:

relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VClone_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VClone_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
../../../lib/libcasadi_sundials.a(nvector_serial.c.o): In function `N_VNewEmpty_Serial':
nvector_serial.c:(.text+0x1f0c): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VCloneEmpty_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f10): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VDestroy_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f14): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VSpace_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f18): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VGetArrayPointer_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f1c): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VSetArrayPointer_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f20): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VLinearSum_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f40): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VConst_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC
nvector_serial.c:(.text+0x1f48): dangerous relocation: unsupported relocation
/usr/bin/ld: ../../../lib/libcasadi_sundials.a(nvector_serial.c.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `N_VProd_Serial' which may bind externally can not be used when making a shared object; recompile with -fPIC

解决--修改CMakeLists.txt

CMakeLists.txt418左右,添加在arm架构上可以使用fPIC的编译设置

修改前:

#######################################################################
############################# -fPIC ###################################
#######################################################################
# the following commands are needed to fix a problem with the libraries
# for linux 64 bits
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  message(STATUS "x86_64 architecture detected - setting flag -fPIC")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
  set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fPIC")
endif()

修改后:

#######################################################################
############################# -fPIC ###################################
#######################################################################
# the following commands are needed to fix a problem with the libraries
# for linux 64 bits
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64"OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
  message(STATUS "x86_64 architecture detected - setting flag -fPIC")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
  set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fPIC")
endif()

编译通过

@meng

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值