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

Runtime error on iOS #1010

Open
l3utterfly opened this issue May 15, 2024 · 6 comments
Open

Runtime error on iOS #1010

l3utterfly opened this issue May 15, 2024 · 6 comments

Comments

@l3utterfly
Copy link

After building for iOS 17, I get this error when loading a model:

sentencepiece::SentencePieceProcessor srcSPM, destSPM;
    auto loadSrcStatus = srcSPM.Load(modelPathStr + "/source.spm");
    auto loadDestStatus = destSPM.Load(modelPathStr + "/target.spm");

Error:

[libprotobuf FATAL /Users/runner/work/1/b/ios_framework/intermediates/iphoneos_arm64/Release/_deps/protobuf-src/src/google/protobuf/stubs/common.cc:83] This program was compiled against version 3.14.0 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.21.12).  Contact the program author for an update.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "/Users/username/Documents/myprogram/cpp/sentencepiece/src/builtin_pb/sentencepiece_model.pb.cc".)
@taku910
Copy link
Collaborator

taku910 commented May 15, 2024

The error message describes the root cause. incompatible protobuf library are used in *.cc and *.h. I guess this library is built with non-standard way. Could you provide the details of how this SentencePiece library was built?

@l3utterfly
Copy link
Author

I cloned the master branch, and generated the xcodeproj file via: cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake -DPLATFORM=OS64

That's it. I'm linking against the static library in my iOS project.

@l3utterfly
Copy link
Author

I looked through the cmake file, by default sentencepiece uses the pre-built generated protobuf. It seems SPM_PROTOBUF_PROVIDER=internal by default. Is the generated protobuf files commited to this repo generated by protobuf 3.14?

@taku910
Copy link
Collaborator

taku910 commented May 19, 2024

I looked through the cmake file, by default sentencepiece uses the pre-built generated protobuf. It seems SPM_PROTOBUF_PROVIDER=internal by default. Is the generated protobuf files commited to this repo generated by protobuf 3.14?

Right. SPM_PROTOBUF_PROVIDER=package will allow you to build the protobuf already installed on your system.

@l3utterfly
Copy link
Author

@taku910 I'm not sure if I understand correctly. If I use SPM_PROTOBUF_PROVIDER=internal, shouldn't the built sentencepiece library use internally provided protobuf library included in this project? Why would it look for protobuf 3.14 that's installed in the iPhone?

@taku910
Copy link
Collaborator

taku910 commented May 30, 2024

It is possible that the linkage is mismatched: in the case of internal, sentencepiece is linking to the internal library. On the other hand, if the parent project (iPhone) is trying to link another version of the sentencepiece, duplication will occur.
SPM_PROTOBUF_PROVIDER=package does only find the sentencepiece package that is installed as a library on the standard linux system., i.e., *so, *h, *a files are all available. Probably the libraries required to build sentence pieces are not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants