中华田园巨龙 2021-12-30 14:40 采纳率: 100%
浏览 31
已结题

GCC编译时找不到内核函数

我有一个头文件ecrt.h,里面包含了一个宏定义#define EC_WRITE_U16 writew(addr,val) 。
按理来说这个头文件是给驱动程序使用的,因为涉及到了内核函数writew。但是我的用户空间也用到了这个头文件ecrt.h,但是没有用到EC_WRITE_U16这个宏定义。
编译过程中出现了如下错误

make  all-recursive
make[3]: Entering directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2/examples'
Making all in dc_user
make[4]: Entering directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2/examples/dc_user'
 cd ../.. && automake-1.16 --gnu examples/dc_user/Makefile
 cd ../.. && /bin/bash ./config.status examples/dc_user/Makefile depfiles
config.status: creating examples/dc_user/Makefile
config.status: executing depfiles commands
/bin/bash ../../libtool  --tag=CC   --mode=link gcc -I../../include -Wall -ffunction-sections -fdata-sections -g -O2 -L../../lib/.libs -lethercat -lrt -Wl,--gc-sections  -o ec_dc_user_example ec_dc_user_example-main.o
libtool: link: gcc -I../../include -Wall -ffunction-sections -fdata-sections -g -O2 -Wl,--gc-sections -o .libs/ec_dc_user_example ec_dc_user_example-main.o  -L../../lib/.libs /home/tsinglin/IGH-1.5.2/ethercat-1.5.2/lib/.libs/libethercat.so -lrt -Wl,-rpath -Wl,/opt/etherlab/lib
/usr/bin/ld: /home/tsinglin/IGH-1.5.2/ethercat-1.5.2/lib/.libs/libethercat.so: undefined reference to `writew'
/usr/bin/ld: /home/tsinglin/IGH-1.5.2/ethercat-1.5.2/lib/.libs/libethercat.so: undefined reference to `writeb'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:408: ec_dc_user_example] Error 1
make[4]: Leaving directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2/examples/dc_user'
make[3]: *** [Makefile:448: all-recursive] Error 1
make[3]: Leaving directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2/examples'
make[2]: *** [Makefile:400: all] Error 2
make[2]: Leaving directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2/examples'
make[1]: *** [Makefile:509: all-recursive] Error 1
make[1]: Leaving directory '/home/tsinglin/IGH-1.5.2/ethercat-1.5.2'
make: *** [Makefile:435: all] Error 2

我已经加了编译参数-ffunction-sections -fdata-sections 和-Wl,--gc-sections ,还是过不去,提示undefined reference to `writew'

请问该如何解决呢?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 1月7日
    • 创建了问题 12月30日

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题