我有一个名为main.cpp的文件,我使用的是具有完整路径的共享库:" /usr/local/lib/libcryptopp.a
"我的include目录是:" /usr/local/include/cryptopp
"。
当我尝试使用此命令构建时:
g++ -o crypto -g main.cpp -I /usr/local/include/cryptopp /usr/local/lib/libcryptopp.a
代码构建完美,可执行文件"加密"被建造。但是当我将编译和链接分开时:
g++ -c -g -I/usr/local/include/cryptopp -o main.o main.cpp
g++ -o crypto main.o -L/usr/lib64 /usr/local/lib/libcryptopp.a
我收到这些错误:
/usr/local/lib/libcryptopp.a(algparam.o): In function `CryptoPP::CombinedNameValuePairs::~CombinedNameValuePairs()':
/home/stsadm/JJ/algparam.h:135: undefined reference to `operator delete(void*, unsigned long)'
/usr/local/lib/libcryptopp.a(pubkey.o): In function `CryptoPP::P1363_MGF1KDF2_Common(CryptoPP::HashTransformation&, unsigned char*, unsigned long, unsigned char const*, unsigned long, unsigned char const*, unsigned long, bool, unsigned int)':
/home/stsadm/JJ/pubkey.cpp:17: undefined reference to `operator delete(void*, unsigned long)'
/usr/local/lib/libcryptopp.a(pubkey.o): In function `CryptoPP::PK_SignatureScheme::InvalidKeyLength::~InvalidKeyLength()':
/home/stsadm/JJ/cryptlib.h:2459: undefined reference to `operator delete(void*, unsigned long)'
/usr/local/lib/libcryptopp.a(pubkey.o): In function `CryptoPP::PK_SignatureScheme::KeyTooShort::~KeyTooShort()':
/home/stsadm/JJ/cryptlib.h:2469: undefined reference to `operator delete(void*, unsigned long)'
/usr/local/lib/libcryptopp.a(pubkey.o): In function `CryptoPP::HashFilter::~HashFilter()':
/home/stsadm/JJ/filters.h:517: undefined reference to `operator delete(void*, unsigned long)'
我 让分离的方式无关紧要。任何想法为什么分离版本给我链接错误?
答案 0 :(得分:0)
为什么包含额外的(尽管是不必要的)库目录导致问题的任何想法?
我能看到的唯一原因是,libstdc++.a
,{em>和中的libstdc++.so
或/usr/lib64
该库在某种程度上已损坏,或者只是丢失了::operator delete
出于某种(意外)原因。
要查看“常规”链接选择了哪个(非损坏的)libstdc++
,请执行以下操作:
g++ -o crypto main.o /usr/local/lib/libcryptopp.a -Wl,-y,_ZdlPvm