期望 - c 程序
我正在尝试使用expect.h 标头编译用c 编写的程序。我正在尝试这个:
cc -I/usr/include main.c -lexpect -ltcl
cc -I/usr/include main.c
我尝试了与 gcc 相同的方法,但没有成功。
我明白了:
undefined reference to `exp_spawnl'
undefined reference to `exp_expectl'
有什么想法吗?
谢谢,
沃尔特
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着无论您认为正在使用什么,正在使用的 Expect 库都不包含这两个函数。因此,您需要跟踪实际加载了哪个期望库,然后检查函数是否在其中(它们不是,但您应该检查定义了什么)。
找到库后,您可以使用 nm -g libexpect.so 来查看定义的符号。我希望您不会在定义的符号列表中看到
exp_spawnl
或exp_expectl
。然后您需要找出您拥有的库的版本,并决定是否升级等。
我假设您引用的名称确实拼写正确。
It means that regardless of what you thought was being used, the expect library being used does not contain those two functions. So, you need to track down which expect library is actually loaded, and then check whether the functions are in it (they aren't, but you should check to see what is defined).
Once you've found your library, you can use
nm -g libexpect.so
to see the symbols defined. I would expect that you will not seeexp_spawnl
orexp_expectl
in the list of defined symbols.Then you need to find out which version of the library you do have, and decide whether to upgrade, etc.
I am assuming that the names you quote are indeed spelled correctly.
Expect头文件是否安装在/usr/include中?
我认为未定义的引用错误来自链接器而不是编译器。库安装到哪个目录? 链接它
尝试使用-L/path/to/lib -lexpect
选项
Is the expect header file installed in /usr/include?
I think the undefined reference error comes from the linker and not the compiler. What directory is the library installed to? Try to link against it using the
-L/path/to/lib -lexpect
option