“对‘strnstr’的未定义引用”安装 cminpack 时

发布于 2024-10-17 01:30:34 字数 1074 浏览 1 评论 0原文

我正在全新安装的 Ubuntu 10.10 上安装 cminpack 1.1.2。

在 cminpack 文件夹中运行 sudo make 时,在 52% 时出现以下错误:

[ 52%] Building C object examples/CMakeFiles/genf77tests.dir/genf77tests.c.o
/usr/lib/cminpack-1.1.2/examples/genf77tests.c: In function ‘main’:
/usr/lib/cminpack-1.1.2/examples/genf77tests.c:44: warning: assignment makes pointer from integer without a cast
/usr/lib/cminpack-1.1.2/examples/genf77tests.c:86: warning: comparison between pointer and integer
Linking C executable genf77tests
CMakeFiles/genf77tests.dir/genf77tests.c.o: In function `main':
genf77tests.c:(.text+0xb5): undefined reference to `strnstr'
genf77tests.c:(.text+0x2a9): undefined reference to `strnstr'
collect2: ld returned 1 exit status
make[2]: *** [examples/genf77tests] Error 1
make[1]: *** [examples/CMakeFiles/genf77tests.dir/all] Error 2
make: *** [all] Error 2

我查看了 genf77tests.c 内部,以及 #include; 存在,所以我不明白为什么查找 strnstr 时出现问题。

我可以做些什么来解决这个问题吗?

I am installing cminpack 1.1.2 on a clean install of Ubuntu 10.10.

When running sudo make in the cminpack folder, the folloing error occurs at 52%:

[ 52%] Building C object examples/CMakeFiles/genf77tests.dir/genf77tests.c.o
/usr/lib/cminpack-1.1.2/examples/genf77tests.c: In function ‘main’:
/usr/lib/cminpack-1.1.2/examples/genf77tests.c:44: warning: assignment makes pointer from integer without a cast
/usr/lib/cminpack-1.1.2/examples/genf77tests.c:86: warning: comparison between pointer and integer
Linking C executable genf77tests
CMakeFiles/genf77tests.dir/genf77tests.c.o: In function `main':
genf77tests.c:(.text+0xb5): undefined reference to `strnstr'
genf77tests.c:(.text+0x2a9): undefined reference to `strnstr'
collect2: ld returned 1 exit status
make[2]: *** [examples/genf77tests] Error 1
make[1]: *** [examples/CMakeFiles/genf77tests.dir/all] Error 2
make: *** [all] Error 2

I have looked inside genf77tests.c, and #include <string.h> is present, so I don't see why there is a problem finding strnstr.

Is there anything I can do to fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜心 2024-10-24 01:30:34

strnstr 是一个非标准函数。具体来说,它不包含在 Glibc 中。编写 genf77test.c 的人没有在 Linux/glibc 上测试它......

strnstr is a non-standard function. Specifically, it is not included in Glibc. Whoever wrote genf77test.c did not test it on Linux/glibc...

烈酒灼喉 2024-10-24 01:30:34

strnstr 不是标准 C;据我所知,它是在 BSD UNIX 系列上提供的。

不过,如果编译中的唯一问题是您可以提供其原型1,并将包含其实现的文件添加到要编译的文件中(例如 这个)。


  1. 实际上,您甚至可能不需要它:如果编译进入链接阶段并在那里失败,您可以解决仅抛出 strnstr 的实现。

strnstr is not standard C; as far as I can see, it's provided on the BSD UNIX family.

Still, if the only problem in your compilation is that one you can provide its prototype1 and add to the files to be compiled one that contains its implementation (for example this one).


  1. Actually, you may not even need it: if the compilation gets to the linking stage and fails just there, you can solve throwing in just the implementation of strnstr.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文