After hours of debugging, I have the following minimalist .proto file:


syntax = "proto3";


message PbCaptureResult {

bool checkedValid = 1;

}


message PbCaptureResultSequence {

PbCaptureResult captureResults = 1;

}

It compiles and links successfully. But, if I add a "repeated" like:


syntax = "proto3";


message PbCaptureResult {

bool checkedValid = 1;

}


message PbCaptureResultSequence {

repeated PbCaptureResult captureResults = 1;

}

then I have a link error and get:


cmd.exe /C "cd . && 
C:\Android\Sdk\ndk\22.0.6917172\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
 
--target=aarch64-none-linux-android29 
--gcc-toolchain=C:/Android/Sdk/ndk/22.0.6917172/toolchains/llvm/prebuilt/windows-x86_64
 
--sysroot=C:/Android/Sdk/ndk/22.0.6917172/toolchains/llvm/prebuilt/windows-x86_64/sysroot
 
-fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables 
-fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 
-Wformat -Werror=format-security  -Wno-deprecated-declarations -O0 
-fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a 
-Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a 
-Wl,--build-id=sha1 -Wl,--fatal-warnings -Wl,--no-undefined 
-Qunused-arguments -shared -Wl,-soname,libnative-lib.so -o libnative-lib.so 
@CMakeFiles/native-lib.rsp  && cd ."

ld: error: undefined symbol: 
google::protobuf::internal::RepeatedPtrFieldBase::AddOutOfLineHelper(void*)

>>> referenced by repeated_field.h:1767 
(../../../../imported-lib/include\google/protobuf\repeated_field.h:1767)

>>>              
 
CMakeFiles/native-lib.dir/src/main/cpp/authenticationLib/CaptureResultSequence.pb.cc.o:(google::protobuf::RepeatedPtrField<PbCaptureResult>::TypeHandler::Type*
 
google::protobuf::internal::RepeatedPtrFieldBase::Add<google::protobuf::RepeatedPtrField<PbCaptureResult>::TypeHandler>(google::protobuf::RepeatedPtrField<PbCaptureResult>::TypeHandler::Type*))

clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)

If the "repeated" come before a "standard type" such as string then it 
compiles:


syntax = "proto3";


message PbCaptureResult {

bool checkedValid = 1;

}


message PbCaptureResultSequence {

repeated string captureResults = 1;

}

it's only if I try to repeat a custom message that I have an issue.


But in the protobuf website I found the following example:


message SearchResponse {

  repeated Result results = 1;

}


message Result {

  string url = 1;

  string title = 2;

  repeated string snippets = 3;

} 

I have put the example as is in my .proto file and it failed to compile 
with the same linking error. I concluded that it's not a .proto syntax 
problem.

It's protobuf 3.15.5.

The generating command is: ./bin/protoc.exe --cpp_out=.. 
CaptureResultSequence.proto

I am static linking against libprotobuf.a (not libprotobuf-lite.a)

I have cross compiled protobuf myself

I initially thought that the issue was related to linking, but for me it 
doesn't explain why I can link without "repeated" but can't link with it.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/035ec0f4-a4fc-4131-b9fc-b97c6a682dfan%40googlegroups.com.

Reply via email to