linux - 编译vmci程序

标签 linux gcc

我正在尝试编译 vmware vmci 示例程序。程序分为两部分

a) 内核模块 b) 示例数据报程序

当我编译该数据报程序时,我收到以下错误:

gcc -I headers_path datagramApp.c
/tmp/cc6KkQ4a.o: In function `main':
datagramApp.c:(.text+0x16c): undefined reference to `VMCI_InitApp'
datagramApp.c:(.text+0x1be): undefined reference to `VMCI_CleanupApp'
/tmp/cc6KkQ4a.o: In function `DoDatagramServer':
datagramApp.c:(.text+0x1e6): undefined reference to `VMCIDatagram_CreateHnd'
datagramApp.c:(.text+0x24f): undefined reference to `VMCIDs_Lookup'
datagramApp.c:(.text+0x2d7): undefined reference to `VMCIResource_AddClientPrivileges'
datagramApp.c:(.text+0x333): undefined reference to `VMCIDs_Register'
datagramApp.c:(.text+0x3bf): undefined reference to `VMCIDatagram_RecvFrom'
datagramApp.c:(.text+0x44f): undefined reference to `VMCIDatagram_SendTo'
datagramApp.c:(.text+0x4a8): undefined reference to `VMCIDs_Unregister'
datagramApp.c:(.text+0x4c0): undefined reference to `VMCIDatagram_DestroyHnd'
/tmp/cc6KkQ4a.o: In function `DoDatagramClient':
datagramApp.c:(.text+0x505): undefined reference to `VMCIDs_Lookup'
datagramApp.c:(.text+0x563): undefined reference to `VMCIDatagram_CreateHnd'
datagramApp.c:(.text+0x608): undefined reference to `VMCIResource_AddClientPrivileges'
datagramApp.c:(.text+0x680): undefined reference to `VMCIDatagram_SendTo'
datagramApp.c:(.text+0x6b8): undefined reference to `VMCIDatagram_RecvFrom'
datagramApp.c:(.text+0x6f7): undefined reference to `VMCIDatagram_DestroyHnd'

TNX

最佳答案

您需要链接一个(共享)对象来获取 VMCI 的用户层接口(interface)

AFAICT 这是来自 Vmware(?) 的专有 API,您应该安装 [1]

典型的编译行看起来更像是:

gcc -I <headers_path> datagramApp.c -lvmci

注释

  • 将 header_path 替换为类似的内容(取决于模块的构建位置)
    • /usr/src/linux/include
    • /opt/vmware/include
  • -lvmci 会建议您的库路径中存在 libvmci.so(记住 sudo ldconfig -a,可以选择包含 -L/path/to/libs 以便让 gcc/ld 找到)它们

[1] 或许作为 Custom Installation of VMware Tools 的一部分?

关于linux - 编译vmci程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5730449/

相关文章:

linux - 如何在haproxy中启用keep-alive?

linux - 在 bash 中处理文本 - 从 pactl sink-inputs 输出中提取程序的体积

c - 以数字作为变量的字符串,Unix C 问题

linux - 我如何知道我的 Linux 服务器上当前安装了哪个版本的 gcc?

c - 使用 pty 使用 GCC 编译时出错

c - GCC错误但VS没有错误

linux - 如何将 GCC 版本从 4.8.3 恢复到 4.8.2?

linux - linux 什么东西占用内存

linux - 在树莓派上安装 Octave

python - 如何将文件从Azure blob复制到Linux中的某些路径