Linking error coming when linking libcryptopp.a

130 views
Skip to first unread message

Rajiv Poplai

unread,
Feb 18, 2015, 1:31:07 PM2/18/15
to cryptop...@googlegroups.com
I created libcrypto.a of CCryptopp 5.6.1 on Mac OS 10.9 using GNUmakefile.
Subsequently when I link it in my project in XCode 5.1.1, I get the following linker error.

CryptoPP:RandomPool::GenerateIntoBufferedTransformation symbol not found.

Can anybody help me with this issue.

thanks,
rajiv

Jeffrey Walton

unread,
Feb 18, 2015, 5:08:07 PM2/18/15
to cryptop...@googlegroups.com
Xcode uses LLVM's libc++ by default. By default, Crpyto++'s GNUmakefile omits CXXFLAGS += -std=libc++, so it uses GNU's libstdc++. The following is from around line 90:

ifeq ($(UNAME),Darwin)
  AR = libtool
  ARFLAGS = -static -o
  CXX = c++
  IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
  ifeq ($(IS_GCC2),1)
    CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
    LDLIBS += -lstdc++
    LDFLAGS += -flat_namespace -undefined suppress -m
  endif
endif

So you will either need to:

  (1) Change Xcode to use GNU's libstdc++
  (2) Rebuild Crypto++ to use LLVM's libc++

To perform (1), change the setting in the Target's build settings.

To perform (2), open the GNUmakefile and add CXXFLAGS += -std=libc++ after one of he Darwin tests (search for Darwin). And get rid of the line:

    LDLIBS += -lstdc++

Jeff

Rajiv Poplai

unread,
Feb 19, 2015, 8:11:34 AM2/19/15
to cryptop...@googlegroups.com
Thanks Jeff, I followed the steps detailed but it is showing one symbol as not found.

CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation &, std::string const&, unsigned long long)
referenced from Vtable for CryptoPP::AutoSeededRandomPool 

This is caused by following statement in code
CryptoPP::AutoSeededRandomPool  rnd;

In the randpool.cpp GenerateIntoBufferedTransformation has the last parameter defined as lword and not unsigned long long. 
Not able to figure out how to rectify this problem.

regards,
rajiv

Jeffrey Walton

unread,
Feb 19, 2015, 3:38:42 PM2/19/15
to cryptop...@googlegroups.com


On Thursday, February 19, 2015 at 8:11:34 AM UTC-5, Rajiv Poplai wrote:
Thanks Jeff, I followed the steps detailed but it is showing one symbol as not found.

CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation &, std::string const&, unsigned long long)
referenced from Vtable for CryptoPP::AutoSeededRandomPool 

This is caused by following statement in code
CryptoPP::AutoSeededRandomPool  rnd;

In the randpool.cpp GenerateIntoBufferedTransformation has the last parameter defined as lword and not unsigned long long. 
Not able to figure out how to rectify this problem
This is just a typedef from config.h:

    #if defined(_MSC_VER) || defined(__BORLANDC__)
      typedef unsigned __int64 word64;
      #define W64LIT(x) x##ui64
    #else
      typedef unsigned long long word64;
      #define W64LIT(x) x##ULL
    #endif

    // define large word type, used for file offsets and such
    typedef word64 lword;
    const lword LWORD_MAX = W64LIT(0xffffffffffffffff);

Please provide the Xcode setting you are using under C++ Standard Library (CLANG_CXX_LIBRARY).

Please provide the output of of lipo. It should look something like this:

    $ xcrun -sdk iphoneos lipo -info /usr/local/lib/libcryptopp.a
    Non-fat file:/usr/local/lib/libcryptopp.a is architecture: x86_64 i386

Please provide the output of the following command:

    nm -g /usr/local/lib/libcryptopp.a | c++filt | grep RandomPool::GenerateIntoBufferedTransformation | grep " T "

Please provide the link command you are using (produced by Xcode).

Jeff

Rajiv Poplai

unread,
Feb 19, 2015, 4:22:47 PM2/19/15
to cryptop...@googlegroups.com


On Friday, February 20, 2015 at 2:08:42 AM UTC+5:30, Jeffrey Walton wrote:


On Thursday, February 19, 2015 at 8:11:34 AM UTC-5, Rajiv Poplai wrote:
Thanks Jeff, I followed the steps detailed but it is showing one symbol as not found.

CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation &, std::string const&, unsigned long long)
referenced from Vtable for CryptoPP::AutoSeededRandomPool 

This is caused by following statement in code
CryptoPP::AutoSeededRandomPool  rnd;

In the randpool.cpp GenerateIntoBufferedTransformation has the last parameter defined as lword and not unsigned long long. 
Not able to figure out how to rectify this problem
This is just a typedef from config.h:

    #if defined(_MSC_VER) || defined(__BORLANDC__)
      typedef unsigned __int64 word64;
      #define W64LIT(x) x##ui64
    #else
      typedef unsigned long long word64;
      #define W64LIT(x) x##ULL
    #endif

    // define large word type, used for file offsets and such
    typedef word64 lword;
    const lword LWORD_MAX = W64LIT(0xffffffffffffffff);

Please provide the Xcode setting you are using under C++ Standard Library (CLANG_CXX_LIBRARY).
libstdc++ 

[~/Documents/ccryptopp]$ lipo -info libcryptopp.a 

input file libcryptopp.a is not a fat file

Non-fat file: libcryptopp.a is architecture: x86_64

 

Please provide the output of the following command:


    nm -g /usr/local/lib/libcryptopp.a | c++filt | grep RandomPool::GenerateIntoBufferedTransformation | grep " T "
 0000000000000310 T CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long)

0000000000002d78 S CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long) (.eh)


Please provide the link command you are using (produced by Xcode).

Ld /Users/rapoplai/git/gocartclient/public/gcclient/libraries/macintosh/universal/debug/GCClient.app/Contents/MacOS/GCClient normal x86_64

    cd /Users/rapoplai/git/gocartclient/build/gcclient/xcode

    export MACOSX_DEPLOYMENT_TARGET=10.7

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/rapoplai/git/gocartclient/public/gcclient/libraries/macintosh/universal/debug -L/Users/rapoplai/git/gocartclient/build/gcclient/xcode/../../../public/services/libraries/macintosh/universal/debug -L/Users/rapoplai/git/gocart/sources/client/public/services/libraries/macintosh/universal/Debug -L/Users/rapoplai/git/gocart/sources/client/public/services/libraries/macintosh/universal/Release -L/Users/rapoplai/git/gocartclient/external/caps/libraries/macintosh/universal/debug -L/Users/rapoplai/git/gocartclient/build/adobe_ialclient/xcode/../../../external/CCryptoPP/5.6.2/lib/mac/10.9 -L/Users/rapoplai/git/gocartclient/external/CCryptoPP/5.6.2/lib/mac/10.9 -L/Users/rapoplai/git/gocartclient/build/adobe_ialclient/xcode -F/Users/rapoplai/git/gocartclient/public/gcclient/libraries/macintosh/universal/debug -filelist /Users/rapoplai/git/gocartclient/obj/gcclient.build/debug/GCClient.build/Objects-normal/x86_64/GCClient.LinkFileList -mmacosx-version-min=10.7 -no_dead_strip_inits_and_terms -Wl -pie -stdlib=libstdc++ -fobjc-link-runtime -lcrypto /Users/rapoplai/git/gocartclient/public/adobe_ialclient/libraries/macintosh/universal/debug/adobe_ialclient.a /Users/rapoplai/git/gocartclient/public/DispatchClient/libraries/macintosh/universal/debug/libdispatchclient.a -lribscaps -lcryptopp /Users/rapoplai/git/gocartclient/public/services/libraries/macintosh/universal/debug/libAMTServiceLoader.a -lsqlite3 -lc++.1 -framework SystemConfiguration -framework Cocoa -Xlinker -dependency_info -Xlinker /Users/rapoplai/git/gocartclient/obj/gcclient.build/debug/GCClient.build/Objects-normal/x86_64/GCClient_dependency_info.dat -o /Users/rapoplai/git/gocartclient/public/gcclient/libraries/macintosh/universal/debug/GCClient.app/Contents/MacOS/GCClient

Jeffrey Walton

unread,
Feb 19, 2015, 6:27:24 PM2/19/15
to cryptop...@googlegroups.com
>> Please provide the Xcode setting you are using under C++ Standard Library (CLANG_CXX_LIBRARY).
> libstdc++ 

>>     nm -g /usr/local/lib/libcryptopp.a | c++filt | grep RandomPool::GenerateIntoBufferedTransformation | grep " T "
0000000000000310 T CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long)

There's your problem :(

Xcode is using GNU's libstdc++. Your libcryptoppa. is using LLVM's libc++.

You can tell because LLVM decorates their symbols with the "__1". I don't know anything else about it  "__1". It may be an actual namespace, or it may be a pseudo-namespace.

Jeff

Rajiv Poplai

unread,
Feb 20, 2015, 1:24:58 AM2/20/15
to cryptop...@googlegroups.com
Thanks Jeff, that indeed solved the problem.

regards,
Rajiv

Manish Gautam

unread,
Aug 18, 2016, 4:33:45 AM8/18/16
to Crypto++ Users
Hi Rajiv,

I have a similar problem. Can you please tell me how your problem get solved?
I need it urgently. Thanks in advance.

Manish Gautam

unread,
Aug 18, 2016, 4:37:28 AM8/18/16
to Crypto++ Users
Hi Rajiv and Jeff,

I have come across a similar issue.

Can you guys please help me with this?
I am getting following error:

Undefined symbols for architecture i386:

  "CryptoPP::HashFilter::HashFilter(CryptoPP::HashTransformation&, CryptoPP::BufferedTransformation*, bool, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:

Please respond Sir.

Jeffrey Walton

unread,
Aug 18, 2016, 7:15:22 PM8/18/16
to Crypto++ Users
Reply all
Reply to author
Forward
0 new messages