简体   繁体   中英

expect - c program

I am trying to compile a program written in c using the expect.h header. 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.

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. 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 see exp_spawnl or exp_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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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