Skip to content

Windows/MSVC 编译失败:bp_stack_of_variable_encode 中使用 stpcpy 导致链接错误 #803

@daiyeqi

Description

@daiyeqi

开启 bulletproofs,编译时提示缺少 stpcpy,stpcpy((char *)p, V->name);

static int bp_stack_of_variable_encode(STACK_OF(BP_VARIABLE) *sk, unsigned char *out,
                                       const EC_GROUP *group, BN_CTX *bn_ctx)
{
    int i, n, *q, size;
    size_t point_len;
    unsigned char *p;
    BP_VARIABLE *V;

    if (sk == NULL || group == NULL)
        return 0;

    point_len = EC_POINT_point2oct(group, EC_GROUP_get0_generator(group),
                                   form, NULL, 0, bn_ctx);
    n = sk_BP_VARIABLE_num(sk);
    if (out == NULL) {
        size = sizeof(n) + n * point_len;
        for (i = 0; i < n; i++) {
            V = sk_BP_VARIABLE_value(sk, i);
            if (V == NULL)
                break;

            if (V->name != NULL) {
                size += strlen(V->name);
            }

            size += 1;
        }

        return size;
    }

    q = (int *)out;
    *q++ = zkp_l2n((int)n);
    p = (unsigned char *)q;

    for (i = 0; i < n; i++) {
        V = sk_BP_VARIABLE_value(sk, i);
        if (V == NULL)
            goto end;

        if (EC_POINT_point2oct(group, V->point, form, p, point_len, bn_ctx) == 0)
            goto end;

        p += point_len;

        if (V->name == NULL) {
            *p++ = '\0';
            continue;
        }

        stpcpy((char *)p, V->name);
        p += strlen(V->name) + 1;
    }

end:
    return p - out;
}

环境:
Windows 2025
Visual Studio 2026

错误

libcrypto-shlib-bulletproofs_encode.obj : error LNK2019: unresolved external symbol stpcpy referenced in function bp_stack_of_variable_encode

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions