使用正在调用TCL脚本的CPP代码的GCC编译
Compiling using gcc of a Cpp code which is calling a TCL script
i有一个CPP代码,其中包括TCL.H库。我正在尝试使用GCC编译器对其进行编译。但是我会收到以下错误:
gcc -o top.o -std=c99 top.c
top.c:12: warning: return type defaults to 'int'
/tmp/ccDOTTZQ.o: In function `main':
top.c:(.text+0xa): undefined reference to `Tcl_CreateInterp'
top.c:(.text+0x1f): undefined reference to `Tcl_EvalFile'
top.c:(.text+0x3d): undefined reference to `Tcl_GetVar2Ex'
top.c:(.text+0x75): undefined reference to `Tcl_ListObjGetElements'
top.c:(.text+0xb1): undefined reference to `Tcl_GetString'
top.c:(.text+0xcc): undefined reference to `Tcl_GetInt'
collect2: ld returned 1 exit status
无法找到CPP-TCL API。请帮助我。
您的代码没有链接到TCL库,因此显然找不到这些功能的实现。(在C和C 中,函数的实现的链接与使用这些函数的声明的使用是一个单独的阶段,这是标题文件提供的。)
除了您实际上将GCC误认为是错误的。您需要使用两个步骤,首先使用-c
到 compile 源代码到对象文件:
gcc -c -o top.o -std=c99 top.c
然后像这样链接结果并制作一个可执行文件:
gcc -o top.exe -std=c99 top.o -ltcl
在第一个情况下,您可能需要另外指定适当的-I
选项以找到Include文件(如果它们不在标准位置)。使用第二个,您可能需要指定一个适当的-L
选项以找到库文件(libtcl.so
)。根据系统的不同,您可能还需要指定某些版本号(例如-ltcl86
或-ltcl8.6
而不是-ltcl
)。这些都是取决于您的构建系统配置的所有选项,因此它们很难在此处准确预测。
相关文章:
- 无法使用犰狳运行编译的 cpp 代码,因为 dyld:库未加载
- 如何大致将 cpp 代码结构转换为 python
- 如何检测 cpp 代码中的 openvino 设备
- Cpp代码故障(显示意外数字)
- CPP代码中出现FileNotFound异常
- 如何在使用模板时将 CPP 代码编译到库文件中
- 编译 cpp 代码
- 为什么我的 cpp 代码显示分段错误
- 由于删除对象而导致的 Cpp 代码主线程冻结可以使用智能指针解决,也可以不使用智能指针来解决
- 使用正在调用TCL脚本的CPP代码的GCC编译
- 错误地将CPP代码与蚊子库一起使用G
- CPP代码方程式返回相同值,无论输入如何
- 更高效的 CPP 代码
- 从 CPP 代码调用 Objective-C 方法
- 这片CPP代码如何转储
- 每当我输入长度为4的字符串时,下面的cpp代码就会崩溃(向量中的malloc失败)
- 在包含 R/Cpp 代码的 R 包中使用 roxygen2 for R 函数
- Opengl cpp 代码可在 Windows 和 Mac 上运行
- XPCOM CPP代码在注册表中找不到现有项
- 使用cpp代码从加载的qml访问qml对象