- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个使用 Boehm GC 的项目,所以我想我可能会使用它自带的 cord
字符串库。问题是我对 cord
函数的所有调用都会导致“ undefined reference ”错误。
我在 /usr/lib
中确实有一个名为 libcord.so
的文件(这是一个 Linux 系统),我告诉 CMake 将目标链接到 gc
和 cord
。
编辑以回应评论 #1:
来自 CMakeLists.txt
target_link_libraries(lang gc)
target_link_libraries(lang cord)
来自错误信息:
../lib/liblang.so: undefined reference to `CORD_substr(char const*, unsigned long, unsigned long)'
../lib/liblang.so: undefined reference to `CORD_len(char const*)'
../lib/liblang.so: undefined reference to `CORD_cat(char const*, char const*)'
../lib/liblang.so: undefined reference to `CORD_cmp(char const*, char const*)'
../lib/liblang.so: undefined reference to `CORD_to_char_star(char const*)'
编辑以回应评论 #2:
$ make -j4 VERBOSE=1
/usr/bin/cmake -H/home/michael/Projects/lang -B/home/michael/Projects/lang/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/michael/Projects/lang/build/CMakeFiles /home/michael/Projects/lang/build/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/michael/Projects/lang/build'
/usr/bin/make -f lib/CMakeFiles/lang.dir/build.make lib/CMakeFiles/lang.dir/depend
make[2]: Entering directory `/home/michael/Projects/lang/build'
cd /home/michael/Projects/lang/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/michael/Projects/lang /home/michael/Projects/lang/lib /home/michael/Projects/lang/build /home/michael/Projects/lang/build/lib /home/michael/Projects/lang/build/lib/CMakeFiles/lang.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/michael/Projects/lang/build'
/usr/bin/make -f lib/CMakeFiles/lang.dir/build.make lib/CMakeFiles/lang.dir/build
make[2]: Entering directory `/home/michael/Projects/lang/build'
make[2]: Nothing to be done for `lib/CMakeFiles/lang.dir/build'.
make[2]: Leaving directory `/home/michael/Projects/lang/build'
/usr/bin/cmake -E cmake_progress_report /home/michael/Projects/lang/build/CMakeFiles 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[ 94%] Built target lang
/usr/bin/make -f src/CMakeFiles/main.dir/build.make src/CMakeFiles/main.dir/depend
make[2]: Entering directory `/home/michael/Projects/lang/build'
cd /home/michael/Projects/lang/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/michael/Projects/lang /home/michael/Projects/lang/src /home/michael/Projects/lang/build /home/michael/Projects/lang/build/src /home/michael/Projects/lang/build/src/CMakeFiles/main.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/michael/Projects/lang/build'
/usr/bin/make -f src/CMakeFiles/main.dir/build.make src/CMakeFiles/main.dir/build
make[2]: Entering directory `/home/michael/Projects/lang/build'
Linking CXX executable lang
cd /home/michael/Projects/lang/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/main.dir/main.cpp.o -o lang -rdynamic ../lib/liblang.so -lgc -lcord -lgmp -Wl,-rpath,/home/michael/Projects/lang/build/lib
../lib/liblang.so: undefined reference to `CORD_substr(char const*, unsigned long, unsigned long)'
../lib/liblang.so: undefined reference to `CORD_len(char const*)'
../lib/liblang.so: undefined reference to `CORD_cat(char const*, char const*)'
../lib/liblang.so: undefined reference to `CORD_cmp(char const*, char const*)'
make[2]: Leaving directory `/home/michael/Projects/lang/build'
make[1]: Leaving directory `/home/michael/Projects/lang/build'
../lib/liblang.so: undefined reference to `CORD_to_char_star(char const*)'
collect2: ld returned 1 exit status
make[2]: *** [src/lang] Error 1
make[1]: *** [src/CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
最佳答案
据我所知,cord.h
文件似乎不包含 extern "C"
中的语句,因此在您编译时名称修改不正确 liblang.so
使用 C++ 编译器。
在源码里你#include <cord.h>
你可能需要这样的东西:
extern "C" {
#include "cord.h"
}
关于c++ - "cord"Boehm GC自带库导致 undefined reference 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5930188/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!