简体   繁体   English

期待 - c程序

[英]expect - c program

I am trying to compile a program written in c using the expect.h header. 我正在尝试使用expect.h头编译用c编写的程序。 I am trying this: 我在尝试这个:

cc -I/usr/include main.c -lexpect -ltcl
cc -I/usr/include main.c

I tried the same with gcc, but to no avail. 我尝试使用gcc,但无济于事。

I get this: 我明白了:

undefined reference to `exp_spawnl'
undefined reference to `exp_expectl'

Any ideas? 有任何想法吗?

Thanks, 谢谢,

Walter 沃尔特

It means that regardless of what you thought was being used, the expect library being used does not contain those two functions. 这意味着无论您如何使用,所使用的expect库都不包含这两个函数。 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. 找到库后,可以使用nm -g libexpect.so查看定义的符号。 I would expect that you will not see exp_spawnl or exp_expectl in the list of defined symbols. 我希望你不会在定义的符号列表中看到exp_spawnlexp_expectl

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. 我假设你引用的名字确实拼写正确。

Is the expect header file installed in /usr/include? 期望头文件是否安装在/ 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 选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM