Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG:Sub Message contains repeated fields Link Error #20621

Open
zjj9850 opened this issue Mar 10, 2025 · 0 comments
Open

BUG:Sub Message contains repeated fields Link Error #20621

zjj9850 opened this issue Mar 10, 2025 · 0 comments
Labels
untriaged auto added to all issues by default when created.

Comments

@zjj9850
Copy link

zjj9850 commented Mar 10, 2025

What version of protobuf and what language are you using?
Version: v29.3
Language: C++
Compile self,and use abseil by internal module.
HEAD detached at v5.29.3

cmake -S . -B build -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -DABSL_PROPAGATE_CXX_STD=ON -Dprotobuf_ABSL_PROVIDER=module  -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF 
cmake --build build --config Release --target install
Image

What operating system (Linux, Windows, ...) and version?
Windows 11

What runtime / compiler are you using (e.g., python version or gcc version)
MSVC
Visual Studio 17 2022

What did you do?
Steps to reproduce the behavior:
1.Define a Message,file is request.proto

message RootMessage
{
    int32 id = 1;

    message SubMessage
    {
        repeated int32 sub_id = 1;
    }

    repeated SubMessage sub_message = 2;
}

2.Write a main.cpp

#include "request.pb.h"
int main()
{
   //Do nothing,only include request.pb.h
   return 0;
}

3.Compile the program

protoc.exe --cpp_out=./pb -I./proto ./proto/request.proto
cl /Zi /std:c++20 /EHsc /W4 /MD /Zc:char8_t- /utf-8 /D "PROTOBUF_USE_DLLS" /Fe:main.exe /I ..\protobuf\include\ main.cpp *.cc /link /LIBPATH:"..\protobuf\lib" libprotobuf.lib abseil_dll.lib

What did you expect to see
Compile Success...

What did you see instead?
request.pb.obj : error LNK2001: "class std::array<char,7> const absl::lts_20240116::log_internal::kCharNull" (?kCharNull@log_internal@lts_20240116@absl@@3v?$array@D$06@std@@b)

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
1.Change the SubMessage Repeated Fields to a normal type

syntax = "proto3";

package ew_proto;


message RootMessage
{
    int32 id = 1;

    message SubMessage
    {
        int32 sub_id = 1;
    }

    repeated SubMessage sub_message = 2;
}

Compile then success...

2.Use dumpbin find the abseil_dll.lib and abseil_dll.lib,kCharNull founded in them.

Image Image
@zjj9850 zjj9850 added the untriaged auto added to all issues by default when created. label Mar 10, 2025
@zjj9850 zjj9850 changed the title Sub Message contains repeated fields Link Error BUG:Sub Message contains repeated fields Link Error Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged auto added to all issues by default when created.
Projects
None yet
Development

No branches or pull requests

1 participant