"undefined reference to `strnstr'" when installing cminpack
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/genf77tes开发者_高级运维ts.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?
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
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).
- 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
.
精彩评论