我编写了以下程序,将十六进制字符串转换为相应的二进制数据。
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char bf[3];
char b; /* each byte */
bf[0] = bf[1] = bf[2] = 0;
for (;;) {
for (;;) {
bf[0] = getchar();
if (isspace(bf[0])) continue;
if (bf[0] == EOF) goto end;
break;
}
for (;;) {
bf[1] = getchar();
if (isspace(bf[1])) continue;
if (bf[1] == EOF) goto end;
break;
}
b = strtoul(bf, NULL, 16);
//printf("%s = %d\n", bf, b);
fwrite(&b, sizeof b, 1, stdout);
}
end:
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
这是一个测试文件: …
这是发生了什么.
$ LDFLAGS=-ltestu01 make exemplo
cc -ltestu01 exemplo.c -o exemplo
/home/melba/tmp/ccO2KkjG.o: In function `main':
exemplo.c:(.text+0x6e): undefined reference to `unif01_CreateExternGenBits'
exemplo.c:(.text+0x7e): undefined reference to `bbattery_SmallCrush'
exemplo.c:(.text+0x8a): undefined reference to `unif01_DeleteExternGenBits'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'exemplo' failed
make: *** [exemplo] Error 1
%
Run Code Online (Sandbox Code Playgroud)
我期待命令cc exemplo.c -o exemplo -ltestu01.如何确保链接器的提示到命令行的末尾?