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

Only support 64bit? #842

Open
logicvv opened this issue Apr 6, 2023 · 2 comments
Open

Only support 64bit? #842

logicvv opened this issue Apr 6, 2023 · 2 comments

Comments

@logicvv
Copy link

logicvv commented Apr 6, 2023

Hi,
I'm trying to compile to 32 bit binary code, which used arm-none-linux-gnueabihf.
However, it seems not work on 32 bits.

The error shows:

/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.so when searching for -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.a when searching for -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: cannot find -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.so when searching for -lsentencepiece
collect2: error: ld returned 1 exit status

Could you please explain why this happen? Or if I just compile this to 64 bit binary code, dose it work?
Does Sentencepiece support to work on any hard devices?

@taku910
Copy link
Collaborator

taku910 commented Apr 7, 2023

Could you elaborate on the build options, command line log and environment?
There is not enough information to comment on anything.

@logicvv
Copy link
Author

logicvv commented Apr 10, 2023

Hi,
Thanks for your reply, the compiler I used is :
arm-none-linux-gnueabihf-g++ (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 10.2.1 20201103

For the complie steps, what I did is:
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/mnt/fileroot/cpp_test/2-sentencepiece ..
CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ make CXXFLAGS=-std=c++17
CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ CXXFLAGS=-std=c++17 make install

Once I have done above steps, and then I tried the command line:
file -L /mnt/fileroot/cpp_test/2-sentencepiece/lib/libsentencepiece.so
it shows this is a 64 bit file.

However, when I compile the testing code, which is:

########################################

#include
#include
#include
#include <sentencepiece_processor.h>

int main() {
// Create a SentencePiece processor
sentencepiece::SentencePieceProcessor sp;
// Load the trained SentencePiece model
sp.Load("./eng.model");
// Encode a sentence
std::string sentence = "This is a test sentence.";
std::vectorstd::string pieces;
sp.Encode(sentence, &pieces);
// Print the encoded pieces
for (const auto& piece : pieces) {
std::cout << piece << " ";
}
std::cout << std::endl;
return 0;
}

#######################
The compile command for this test file is:

arm-none-linux-gnueabihf-g++ -std=c++17 -march=armv8-a -o myapp main.cpp -lsentencepiece -I./2-sentencepiece/include -L./2-sentencepiece/lib -Wl,-rpath-link,./2-sentencepiece/lib

which shows an error:
./2-sentencepiece/lib/libsentencepiece.so: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status

And then I used same complier to complied another c++ code, which does not dependent on sentencepiece, and I tried:
file myapp

and it shows it is a 32 bit file.

So, the error might be the test code and the sentencepiece are different bit files.

Then I want to transfer the sentencepiece to 32bit manually, which used:
##############################

cmake -DCMAKE_INSTALL_PREFIX=/mnt/fileroot/tingting.dong/cpp_test/2-sentencepiece -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ make CXXFLAGS=-std="c++17 -m32"
CXX=arm-none-linux-gnueabihf-g++ CXXFLAGS="-std=c++17 -m32" make install
#####################################

Then I checked the file is it compiled to 32bit, then I tried to compile the test code again, and it shows the error:

/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.so when searching for -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.a when searching for -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: cannot find -lsentencepiece
/opt/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.2.1/../../../../arm-none-linux-gnueabihf/bin/ld: skipping incompatible ./2-sentencepiece/lib/libsentencepiece.so when searching for -lsentencepiece
collect2: error: ld returned 1 exit status

Plese give me any hint how this can work? Thank you.

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