gpt4 book ai didi

c - 对 'XtInitialize' 的 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:49:10 24 4
gpt4 key购买 nike

我正在尝试在 Ubuntu linux 上编译和链接 Athena Xt 程序。

我已经将程序编译成目标文件,但无论如何我都无法将它与 Xt 库链接。

我的链接器调用是

ld /usr/lib/x86_64-linux-gnu/libXt.a program.o

我收到此链接器错误

program.o: In function `main':
program.c:(.text+0x37): undefined reference to `XtInitialize'
program.c:(.text+0x42): undefined reference to `commandWidgetClass'
program.c:(.text+0x5e): undefined reference to `XtCreateManagedWidget'
program.c:(.text+0x75): undefined reference to `XtStrings'
program.c:(.text+0x7d): undefined reference to `XtAddCallback'
program.c:(.text+0x89): undefined reference to `XtRealizeWidget'
program.c:(.text+0x8e): undefined reference to `XtMainLoop'

我用 nm 探测了 Xt 库,那里有符号:

nm /usr/lib/x86_64-linux-gnu/libXt.a | grep XtInitialize
U _XtInitializeActionData
0000000000000360 T XtInitializeWidgetClass
00000000000018b0 T XtInitialize
U XtInitializeWidgetClass
00000000000006d0 T _XtInitializeActionData
U XtInitializeWidgetClass

知道哪里出了问题吗?

最佳答案

尝试:

ld  program.o /usr/lib/x86_64-linux-gnu/libXt.a

ld 的参数顺序很重要,它希望在带有引用的目标文件之后找到库。

关于c - 对 'XtInitialize' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33617367/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com