代码:
char index2key(u64 index, char* key, u32 l_min, u32 l_max, const char* charset, u32 n_charset)
{
u32 l_key = l_min;
u64 n_key = pow(n_charset, l_min);
while (index >= n_key)
{
index -= n_key;
n_key *= n_charset;
l_key++;
}
if (l_key > l_max)
return 0;
for (u32 i = 0; i < l_key; i++, key++)
{
*key = charset[index % n_charset];
index /= n_charset;
}
return 1;
}
当我使用docker构建时出现错误:
Step 5/8 : RUN apt-get install -y build-essential git vim
---> Using cache
---> 6922ee2f0d9d
Step 6/8 : COPY * /build/
---> 4ba9cf1a6281
Step 7/8 : RUN make
---> Running in 6d369aa32323
gcc -Wall -Wextra -Werror -ansi -pedantic -std=c99 -O3 -D_XOPEN_SOURCE=700 -g -c rtgen.c -o rtgen.o
gcc -Wall -Wextra -Werror -ansi -pedantic -std=c99 -O3 -D_XOPEN_SOURCE=700 -g -c md5.c -o md5.o
gcc -Wall -Wextra -Werror -ansi -pedantic -std=c99 -O3 -D_XOPEN_SOURCE=700 -g -c rtable.c -o rtable.o
gcc -O3 -lm -lpthread rtgen.o md5.o rtable.o -o rtgen
/usr/bin/ld: rtable.o: in function `index2key':
/build/rtable.c:249: undefined reference to `pow'
/usr/bin/ld: /build/rtable.c:249: undefined reference to `pow'
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: rtgen] Error 1
rm rtgen.o rtable.o md5.o
The command '/bin/sh -c make' returned a non-zero code: 2