mardi 3 mars 2015

file was built for archive which is not the architecture being linked (x86_64)


I use makefile to compile my C++ program, but it shows a warning:



make
g++ -g -std=c++0x -o ns-client main.cpp Client.cpp TCPConnect.cpp RSAsample.cpp libStatic/libchilkat_i386.a libStatic/libchilkat_x86_64.a -lpthread
ld: warning: ignoring file libStatic/libchilkat_i386.a, file was built for archive which is not the architecture being linked (x86_64): libStatic/libchilkat_i386.a


My makefile is as follows:



cat Makefile
LIBS = libStatic/libchilkat_i386.a libStatic/libchilkat_x86_64.a -lpthread
GPP = g++ -g -std=c++0x
TARGET = -o ns-client
CPP = main.cpp Client.cpp TCPConnect.cpp RSAsample.cpp

all:
$(GPP) $(TARGET) $(CPP) $(LIBS)
clean:
rm ns-client


libchilkat_i386.a and libchilkat_x86_64.a are downloaded by me, not implemented by me. I put them under a directory called "libStatic". These are all my C++ files and lib:



ls
Client.cpp RSAsample.cpp libStatic
Client.h RSAsample.h main.cpp
Client_Common.h TCPConnect.cpp ns-client
Common_Num_Define.h TCPConnect.h ns-client.dSYM
Common_Protocol.h include ns-server
Makefile libDyn


In libStatic directory, it has:



ls
libchilkat_i386.a libchilkat_x86_64.a


I don't know why this warning happens. Even though it has this warning, it still compile successfully. But when I upload them to our school's server and compile them(I definitely upload these static libs), it shows:



undefined reference to


Many these kinds of errors. For example:



/home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:17: undefined reference to `CkRsa::exportPublicKey()'


All these functions and vars which are mentioned in these kinds of errors should be included in libchilkat_i386.a libchilkat_x86_64.a So I doubt maybe it is because of my Makefile.But I am not sure. I also doubt that maybe related to the first warning. Can somebody tells me how solve the first warning or why it cannot compile on another machine but can compile on my own machine? Thanks for everyone's help!


This is all errors it showed on our school's server:



/tmp/ccA32Kao.o: In function `My_RSA::My_RSA()':
main.cpp:(.text._ZN6My_RSAC2Ev[_ZN6My_RSAC5Ev]+0x19): undefined reference to `CkRsa::CkRsa()'
main.cpp:(.text._ZN6My_RSAC2Ev[_ZN6My_RSAC5Ev]+0x2b): undefined reference to `CkRsa::CkRsa()'
main.cpp:(.text._ZN6My_RSAC2Ev[_ZN6My_RSAC5Ev]+0x3d): undefined reference to `CkRsa::CkRsa()'
main.cpp:(.text._ZN6My_RSAC2Ev[_ZN6My_RSAC5Ev]+0x54): undefined reference to `CkRsa::~CkRsa()'
main.cpp:(.text._ZN6My_RSAC2Ev[_ZN6My_RSAC5Ev]+0x69): undefined reference to `CkRsa::~CkRsa()'
/tmp/ccA32Kao.o: In function `My_RSA::~My_RSA()':
main.cpp:(.text._ZN6My_RSAD2Ev[_ZN6My_RSAD5Ev]+0x1a): undefined reference to `CkRsa::~CkRsa()'
main.cpp:(.text._ZN6My_RSAD2Ev[_ZN6My_RSAD5Ev]+0x2c): undefined reference to `CkRsa::~CkRsa()'
main.cpp:(.text._ZN6My_RSAD2Ev[_ZN6My_RSAD5Ev]+0x3c): undefined reference to `CkRsa::~CkRsa()'
/tmp/cciEnFVR.o: In function `Client::Register()':
/home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:17: undefined reference to `CkRsa::exportPublicKey()'
/home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:18: undefined reference to `CkRsa::exportPrivateKey()'


/tmp/cciEnFVR.o: In function Client::Login()': /home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:128: undefined reference toCkRsa::exportPublicKey()' /home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:129: undefined reference to CkRsa::exportPrivateKey()' /tmp/cciEnFVR.o: In functionClient::Judge_Command(char*)': /home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:930 : undefined reference to CkRsa::exportPrivateKey()' /home/users/liuly/liuly/networksecurity/project/cplus/client/Client.cpp:931: undefined reference toCkRsa::exportPublicKey()' /tmp/ccRMXreb.o: In function My_RSA::MyEncryption(char const*, char const*)': /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 16: undefined reference toCkRsa::put_EncodingMode(char const*)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 17: undefined reference to CkRsa::ImportPublicKey(char const*)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 25: undefined reference toCkRsa::encryptStringENC(char const*, bool)' /tmp/ccRMXreb.o: In function My_RSA::MyDecryption(char*)': /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 33: undefined reference toCkRsa::put_EncodingMode(char const*)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 34: undefined reference to CkRsa::ImportPrivateKey(char const*)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 42: undefined reference toCkRsa::decryptStringENC(char const*, bool)' /tmp/ccRMXreb.o: In function My_RSA::My_Initial_Key()': /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 52: undefined reference toCkRsa::UnlockComponent(char const*)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 58: undefined reference to CkRsa::GenerateKey(int)' /home/users/liuly/liuly/networksecurity/project/cplus/client/RSAsample.cpp: 61: undefined reference toCkMultiByteBase::lastErrorText()' collect2: error: ld returned 1 exit status make: *** [all] Error 1


All these functions which should belong to CKRsa are in #include "include/CkRsa.h", but I definitely create the "include" directory on our school's server and upload these CKRsa.h files in that directory.


I revise my makefile,but it still doesn't work:



cat Makefile
LFLAGS += -L /home/users/liuly/liuly/networksecurity/project/cplus/client/libStatic
LIBS = libStatic/libchilkat_x86_64.a -lpthread
GPP = g++ -g -std=c++0x
TARGET = -o ns-client
CPP = main.cpp Client.cpp TCPConnect.cpp Common_Protocol.h RSAsample.cpp TCPConnect.h Client.h RSAsample.h include/CkRsa.h

all:
$(GPP) $(LFLAGS) $(TARGET) $(CPP) $(LIBS)


I revise makefile again, but it still doesn't work:



cat Makefile
LFLAGS += -L /home/users/liuly/liuly/networksecurity/project/cplus/client/libStatic
LIBS = -lchilkat_x86_64 -lpthread
GPP = g++ -g -std=c++0x
TARGET = -o ns-client
CPP = main.cpp Client.cpp TCPConnect.cpp Common_Protocol.h RSAsample.cpp TCPConnect.h Client.h RSAsample.h include/CkRsa.h

all:
$(GPP) $(LFLAGS) $(TARGET) $(CPP) $(LIBS)



Aucun commentaire:

Enregistrer un commentaire