“对‘strnstr’的未定义引用”安装 cminpack 时
我正在全新安装的 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 内部,以及 #includestrnstr
时出现问题。
我可以做些什么来解决这个问题吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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...strnstr
不是标准 C;据我所知,它是在 BSD UNIX 系列上提供的。不过,如果编译中的唯一问题是您可以提供其原型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).
strnstr
.