FS#16247 - [crypto++] unable to link

Attached to Project: Arch Linux
Opened by Caleb Cushing (xenoterracide) - Friday, 18 September 2009, 15:15 GMT
Last edited by Giovanni Scafora (giovanni) - Friday, 18 September 2009, 18:41 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Giovanni Scafora (giovanni)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

/*the code*/
#include <cryptopp/sha.h>
#include <cryptopp/hex.h>
#include <cryptopp/files.h>
#include <boost/filesystem.hpp>
#include <string>
#include <iostream>

using namespace std;
using namespace boost::filesystem;

string getSha1Hash(const path &file, bool uppercase)
{
string result;
CryptoPP::SHA1 hash;
CryptoPP::FileSource(file.file_string().c_str(),true,
new CryptoPP::HashFilter(hash, new
CryptoPP::HexEncoder(
new CryptoPP::StringSink(result),uppercase)));
return result;

}

int main()
{
string sha1;
path file("test.txt");
sha1 = getSha1Hash(file, true);
cout << sha1 << endl;

}

compiler command and output
g++ -lboost_filesystem -lcryptopp sha1.cpp

tmp/cctxcX1W.o: In function `getSha1Hash
(boost::filesystem::basic_path<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
boost::filesystem::path_traits> const&,
bool)':
sha1.cpp:(.text+0x5a): undefined reference to
`CryptoPP::StringSinkTemplate<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >::StringSinkTemplate
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>&)'

sha1.cpp:(.text+0x117): undefined reference to
`CryptoPP::DEFAULT_CHANNEL'
sha1.cpp:(.text+0x11d): undefined reference to
`CryptoPP::DEFAULT_CHANNEL'
sha1.cpp:(.text+0x133): undefined reference to
`CryptoPP::HashFilter::HashFilter(CryptoPP::HashTransformation&,
CryptoPP::BufferedTransformation*, bool, int, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&)'
/tmp/cctxcX1W.o: In function
`CryptoPP::BufferedTransformation::BufferedTransformation
()':
...

according to crypto++ mailing list code works elsewhere (ubuntu). link to cryptopp dialog

http://groups.google.com/group/cryptopp-users/msg/2b00aae8cbfdb461?


This task depends upon

Closed by  Giovanni Scafora (giovanni)
Friday, 18 September 2009, 18:41 GMT
Reason for closing:  Not a bug
Comment by Giovanni Scafora (giovanni) - Friday, 18 September 2009, 18:40 GMT
These two commands work for me.

g++ -c -o sha1.o sha1.cpp
g++ -o sha1 sha1.o -lcryptopp -lboost_filesystem

Since sha1.o requires symbols from libcryptopp.a it should appear first on the command line.
For some reason not all systems are that strict when it comes to library order.

Loading...