Using Crypto++ with clang

View: New views
4 Messages — Rating Filter:   Alert me  

Using Crypto++ with clang

by Ben Crowhurst-4 :: Rate this Message:

| View Threaded | Show Only this Message

I'm attempting to get the following Crypto++ example to work on a iMac
using clang++.

**Example**

SHA256 hash;

byte digest[ SHA256:IGESTSIZE ];

hash.CalculateDigest( digest, (byte*) &value[ 0 ], value.size( ) );

HexEncoder encoder;

string result = String::empty;

encoder.Attach( new StringSink( result ) );

encoder.Put( digest, sizeof( digest ) );

encoder.MessageEnd( );


**Build command**

Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM
3.0svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
 "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.7.4 -emit-obj -
mrelax-all -disable-free -disable-llvm-verifier -main-file-name
checksum_impl.cpp -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -
masm-verbose -munwind-tables -target-cpu core2 -target-linker-version
123.2.1 -v -resource-dir /usr/bin/../lib/clang/2.1 -D
framework_EXPORTS -I /Users/Ben/Dropbox/appon/build/../source -nostdinc
++ -cxx-isystem /usr/include/c++/v1 -Wall -Wextra -Weffc++ -pedantic -
std=c++0x -fdeprecated-macro -ferror-limit 19 -fmessage-length 175 -
stack-protector 1 -fblocks -fcxx-exceptions -fexceptions -fdiagnostics-
show-option -fcolor-diagnostics -o CMakeFiles/framework.dir/Users/Ben/
Dropbox/source/example.cpp.o -x c++ /Users/Ben/Dropbox/source/
example.cpp
clang -cc1 version 2.1 based upon llvm 3.0svn hosted on x86_64-apple-
darwin11.4.0
#include "..." search starts here:
#include <...> search starts here:
 /Users/Ben/Dropbox/build/../source
 /usr/include/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/2.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.


**Linker output**

clang: warning: argument unused during compilation: '-std=c++0x'
Undefined symbols for architecture x86_64:
  "CryptoPP::Filter::TransferTo2(CryptoPP::BufferedTransformation&,
unsigned long long&, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
bool)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
  "CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&,
unsigned long long&, unsigned long long, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)
const", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::ChannelCreatePutSpace(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
unsigned long&)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::ChannelPut2(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
unsigned char const*, unsigned long, int, bool)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::ChannelPutModifiable2(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
unsigned char*, unsigned long, int, bool)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::ChannelFlush(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool,
int, bool)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::ChannelMessageSeriesEnd(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&, int,
bool)", referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
 
"CryptoPP::BufferedTransformation::SetRetrievalChannel(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&)",
referenced from:
      vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
      vtable for CryptoPP::Bufferless<CryptoPP::Filter> in
checksum_impl.cpp.o
      vtable for CryptoPP::Unflushable<CryptoPP::Filter> in
checksum_impl.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [all] Error 2



I'm using the latest development version of Crypto++ 5.6.2 as the
previous version 5.6.1 fails to build with clang++. However i'm
encountering build issues stating that i have missing symbols for
x86_64 architecture.

Any hints would be greatly appreciated.

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.

Re: Using Crypto++ with clang

by David Irvine-2 :: Rate this Message:

| View Threaded | Show Only this Message

Looks like you are trying to use c++0x and an old clang. Either upgrade to 3.1 (clang/llvm) or take this flag out. If passing c++11 flag for later clang you need -stdlib=libc++ as well in compiler and linker flags. 

On Mon, Jun 4, 2012 at 10:58 AM, Ben Crowhurst <crowhurst.ben@...> wrote:
'-std=c++0x'

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.

Re: Using Crypto++ with clang

by Ben Crowhurst-4 :: Rate this Message:

| View Threaded | Show Only this Message

First of thanks for you time. Secondly sorry for the delay i've been a bit busy as of late.

I've taken your comments on board and upgrade by build environment, however I've found that the error is caused by -stdlib=libc++. If I build with the following command everything is ok. However I wish to use libc++ and not stdlibc++. Are you aware of a work around?

*works*
clang++ -l cryptopp cryptopp_test.cpp -o cryptopp_test -std=c++11 

*Fails*
clang++ -l cryptopp cryptopp_test.cpp -o cryptopp_test -std=c++11 -stdlib=libc++


On Monday, 4 June 2012 11:10:11 UTC+1, David Irvine wrote:
Looks like you are trying to use c++0x and an old clang. Either upgrade to 3.1 (clang/llvm) or take this flag out. If passing c++11 flag for later clang you need -stdlib=libc++ as well in compiler and linker flags. 

On Mon, Jun 4, 2012 at 10:58 AM, Ben Crowhurst <crowhurst.ben@...> wrote:
'-std=c++0x'

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.

Re: Using Crypto++ with clang

by David Irvine-2 :: Rate this Message:

| View Threaded | Show Only this Message

Your command line is correct, there are a couple of issues that are patched in our version. There is a patch by Fraser Hutchison that fixes this, if you search this list you will find it. 
All the best
David 
On Sat, Jun 16, 2012 at 12:34 PM, Ben Crowhurst <crowhurst.ben@...> wrote:
First of thanks for you time. Secondly sorry for the delay i've been a bit busy as of late.

I've taken your comments on board and upgrade by build environment, however I've found that the error is caused by -stdlib=libc++. If I build with the following command everything is ok. However I wish to use libc++ and not stdlibc++. Are you aware of a work around?

*works*
clang++ -l cryptopp cryptopp_test.cpp -o cryptopp_test -std=c++11 

*Fails*
clang++ -l cryptopp cryptopp_test.cpp -o cryptopp_test -std=c++11 -stdlib=libc++


On Monday, 4 June 2012 11:10:11 UTC+1, David Irvine wrote:
Looks like you are trying to use c++0x and an old clang. Either upgrade to 3.1 (clang/llvm) or take this flag out. If passing c++11 flag for later clang you need -stdlib=libc++ as well in compiler and linker flags. 

On Mon, Jun 4, 2012 at 10:58 AM, Ben Crowhurst <crowhurst.ben@...> wrote:
'-std=c++0x'

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.