Comments (11)
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?
from sentencepiece.
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.
from sentencepiece.
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?
from sentencepiece.
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.
from sentencepiece.
@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?
from sentencepiece.
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.
from sentencepiece.
@l3utterfly were you able to find a work-around? I am seeing the same issue.
Thank you!
from sentencepiece.
@iprovalo I believe the issue was with iOS minimum version. I recently upgraded to support minimum version iOS 15.5 and the problem went away
from sentencepiece.
@l3utterfly thank you very much!
from sentencepiece.
I am still running into this issue if I use a static xcframework.
The way I am building it is by first adding this modification to CMakeList.txt (to avoid Unknown CMake command "set_xcode_property"
):
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
set_property(TARGET ${TARGET} PROPERTY
XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
endmacro(set_xcode_property)
endif()
Then creating both a dynamic and static xcframework like so (I tried the deployment target 15.5, same results):
set -e
TEAM_ID="XXX"
DEPLOYMENT_CONFIG=Release
ARCH="arm64;x86_64"
DEPLOYMENT_TARGET="15.5"
SOURCE_DIR="src/"
SOURCE_3RD_PARTY_DIR="third_party/"
BUILD_DIR=build-ios
DEST_HEADER_DIR="${BUILD_DIR}/include"
rm -Rf "${BUILD_DIR}"
cmake -B${BUILD_DIR} -GXcode -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET \
-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM="$TEAM_ID" \
-DCMAKE_OSX_ARCHITECTURES=$ARCH
mkdir -p "${DEST_HEADER_DIR}"
cd ${BUILD_DIR}
xcodebuild -configuration $DEPLOYMENT_CONFIG -sdk iphoneos -target sentencepiece
xcodebuild -configuration $DEPLOYMENT_CONFIG -sdk iphoneos -target sentencepiece-static
xcodebuild -configuration $DEPLOYMENT_CONFIG -sdk iphonesimulator -target sentencepiece
xcodebuild -configuration $DEPLOYMENT_CONFIG -sdk iphonesimulator -target sentencepiece-static
cd ../
find "${SOURCE_DIR}" -name '*.h' | while read -r header; do
relative_dir=$(dirname "${header#${SOURCE_DIR}/}")
echo "copying $header to ${DEST_HEADER_DIR}/$relative_dir"
mkdir -p "${DEST_HEADER_DIR}/${relative_dir}"
cp "${header}" "${DEST_HEADER_DIR}/${relative_dir}"
done
echo "Headers copied to ${DEST_HEADER_DIR}"
find "${SOURCE_3RD_PARTY_DIR}" -name '*.h' | while read -r header; do
relative_dir=$(dirname "${header#${SOURCE_3RD_PARTY_DIR}/}")
echo "copying $header to ${DEST_HEADER_DIR}/${SOURCE_3RD_PARTY_DIR}/$relative_dir"
mkdir -p "${DEST_HEADER_DIR}/${SOURCE_3RD_PARTY_DIR}/${relative_dir}"
cp "${header}" "${DEST_HEADER_DIR}/${SOURCE_3RD_PARTY_DIR}/${relative_dir}"
done
echo "Third party Headers copied to ${DEST_HEADER_DIR}"
DEVICE_DIR=${BUILD_DIR}/src/${DEPLOYMENT_CONFIG}-iphoneos
SIMULATOR_DIR=${BUILD_DIR}/src/${DEPLOYMENT_CONFIG}-iphonesimulator
XCFRAMEWORK_DIR=${BUILD_DIR}/${DEPLOYMENT_CONFIG}-universal
xcodebuild -create-xcframework \
-library ${DEVICE_DIR}/libsentencepiece.a \
-headers ${DEST_HEADER_DIR} \
-library ${SIMULATOR_DIR}/libsentencepiece.a \
-headers ${DEST_HEADER_DIR} \
-output ${XCFRAMEWORK_DIR}-static/sentencepiece.xcframework
xcodebuild -create-xcframework \
-library ${DEVICE_DIR}/libsentencepiece.0.0.0.dylib \
-headers ${DEST_HEADER_DIR} \
-library ${SIMULATOR_DIR}/libsentencepiece.0.0.0.dylib \
-headers ${DEST_HEADER_DIR} \
-output ${XCFRAMEWORK_DIR}/sentencepiece.xcframework
from sentencepiece.
I ended up wrapping the static sentencepiece lib in an XCode Framework, and it worked.
from sentencepiece.
Related Issues (20)
- No make file found while build and install the Python wrapper HOT 2
- Tokenize at the word level without spacers nor joiners HOT 2
- Build sentencepiece with mingw HOT 1
- Tokenization for phonetic languages HOT 3
- Convert SentencePiece .vocab format to OpenNMT-py .onmt_vocab format HOT 1
- I want to obtain a model file using my vocab! HOT 1
- resume/restart training of tokenizer HOT 3
- How long does it take to train 31.2GB text data? HOT 1
- How to deal with id HOT 3
- Wrong calculation of max_score in unigram_model.cc
- install command line tools without sudo HOT 1
- Error HOT 1
- Windows pip Dependancy Installation Error HOT 2
- Any api for setting user defined symbols? HOT 1
- Inconsistent result between py and cpp HOT 1
- Error when running this command: pip install 'transformers[tf-cpu]' on mac HOT 1
- Support for Windows Python 3.12.2
- Is GGUF supported? HOT 1
- Treat Hawaiian Glottal stop as consonant, not punctuation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentencepiece.