You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: /usr/bin/ld: build/.objs/test/linux/x86_64/release/src/main.c.o: warning: relocation against `asn_DEF_Rectangle' in read-only section `.text.startup'
/usr/bin/ld: build/.objs/test/linux/x86_64/release/src/main.c.o: in function `main':
main.c:(.text.startup+0x77): undefined reference to `asn_DEF_Rectangle'
/usr/bin/ld: main.c:(.text.startup+0x8f): undefined reference to `der_encode'
/usr/bin/ld: main.c:(.text.startup+0xd2): undefined reference to `xer_fprint'
/usr/bin/ld: main.c:(.text.startup+0x110): undefined reference to `asn_DEF_Rectangle'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
[ 60%]: linking.release test
/usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/src/main.c.o -m64 -s
/usr/bin/ld: build/.objs/test/linux/x86_64/release/src/main.c.o: warning: relocation against `asn_DEF_Rectangle' in read-only section `.text.startup'
/usr/bin/ld: build/.objs/test/linux/x86_64/release/src/main.c.o: in function `main':
main.c:(.text.startup+0x77): undefined reference to `asn_DEF_Rectangle'
/usr/bin/ld: main.c:(.text.startup+0x8f): undefined reference to `der_encode'
/usr/bin/ld: main.c:(.text.startup+0xd2): undefined reference to `xer_fprint'
/usr/bin/ld: main.c:(.text.startup+0x110): undefined reference to `asn_DEF_Rectangle'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
error: @programdir/core/main.lua:309: @programdir/actions/build/main.lua:148: @programdir/modules/async/runjobs.lua:320: @programdir/actions/build/kinds/binary.lua:74: @programdir/core/sandbox/modules/os.lua:378: execv(/usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/src/main.c.o -m64 -s) failed(1)
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:923]:
[@programdir/core/sandbox/modules/os.lua:378]: in function 'execv'
[@programdir/modules/core/tools/gcc.lua:526]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:280]:
[@programdir/core/tool/linker.lua:224]: in function 'link'
[@programdir/actions/build/kinds/binary.lua:74]: in function 'callback'
[@programdir/modules/core/project/depend.lua:217]: in function 'on_changed'
[@programdir/actions/build/kinds/binary.lua:55]: in function '_do_link_target'
[@programdir/actions/build/kinds/binary.lua:105]:
[@programdir/actions/build/kinds/binary.lua:132]: in function '_link_target'
[@programdir/actions/build/kinds/binary.lua:160]: in function 'jobfunc'
[@programdir/modules/async/runjobs.lua:237]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:280]: in function 'trycall'
[@programdir/core/sandbox/modules/try.lua:117]: in function 'try'
[@programdir/modules/async/runjobs.lua:220]: in function 'cotask'
[@programdir/core/base/scheduler.lua:404]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:923: in function 'base/os.raiselevel'
(...tail calls...)
@programdir/core/main.lua:309: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:404: in function <@programdir/core/base/scheduler.lua:397>
Xmake 版本
2.8.5
操作系统版本和架构
Ubuntu 23.10
描述问题
tests/projects/c/asn1c 的样例项目无法正确构建。执行
xmake
后,报错:期待的结果
正确编译并链接
工程配置
与 tests/projects/c/asn1c 相同。
附加信息和错误日志
通过
-vD
参数可发现,在链接程序时未找到asn1c
生成的.c
的编译对象文件。进一步跟进 xmake 源码
asn1c
规则的定义,可注意到问题似乎出现在如下代码:xmake/xmake/rules/asn1c/xmake.lua
Lines 33 to 40 in b1a69af
其中第 33 行向批处理代码添加对
asn1c
的执行命令(以从 ASN.1 定义生成 C 文件),但是该命令在此时刻并未实际执行,目标路径甚至还可能不存在。随后第 36 行直接遍历目标路径下的.c
文件,这在首次编译以及xmake clean -a
之后会得到空的文件集合,并未成功修改target:objectfiles()
。一种可能的修改方法:将遍历
.c
文件并添加objectfiles
的逻辑移动到on_buildcmd_file
,即:如果这看上去是合理的,我可以提交一份 PR。
The text was updated successfully, but these errors were encountered: