Trouble linking against libcryptopp.a in Cygwin/MingW64

50 views
Skip to first unread message

b...@cadamail.com

unread,
Dec 6, 2017, 12:59:27 PM12/6/17
to cryptop...@googlegroups.com
Hello,
I may be doing something incorrectly, if so I apologize and look forward
to being corrected. However, whenever I link against libcrypto, I get
undefined reference errors. Here's what I've done, step by step.

1) Install Cygwin x86_64
2) Install Cygwin packages:
* make
* x86_64-w64-mingw32-gcc
* x86_64-w64-mingw32-g++
* git
* wget
* nano
* diffutils

3) cd /home/user/my_app
4) git clone https://github.com/weidai11/cryptopp && cd cryptopp
5) make
6) make test
7) mkdir -p include/cryptoppp
8) mkdir lib
9) cp *.h include/cryptopp
10) cp *.a lib
11) cd /home/user/my_app
12) echo "test 1 2 3" > test.txt
13) nano test.cpp
------------------------------------------
/* Simple test application for Crypto++ */
// Include Crypto++ headers
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 // For MD5 hash function
#include <cryptopp/md5.h>
#include <cryptopp/hex.h>
#include <cryptopp/files.h>
// Include standard headers
#include <string>
#include <iostream>

std::string filename = "test.txt";
std::string result; // set global result var

// =======================
// Hash Function by button
// =======================
int main() {
// Start MD5 Hashing process
CryptoPP::Weak::MD5 hash;
CryptoPP::FileSource(filename.c_str(),true,
new CryptoPP::HashFilter(hash, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(result), true)));

// Print result to terminal
std::cout << result << std::endl;
}
--------------------------------------------
14) x86_64-w64-mingw32-g++.exe std=c++14 -o test test.cpp
-I/home/user/my_app/cryptopp/include/ -L/home/user/my_app/cryptopp/lib/
-lcryptopp

15) Get this nasty result:
----
/tmp/ccL1UIhb.o:test.cpp:(.text+0x8c): undefined reference to
`CryptoPP::StringSinkTemplate<std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >
>::StringSinkTemplate(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >&)'
/tmp/ccL1UIhb.o:test.cpp:(.text+0x171): undefined reference to
`CryptoPP::HashFilter::HashFilter(CryptoPP::HashTransformation&,
CryptoPP::BufferedTransformation*, bool, int,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccL1UIhb.o:test.cpp:(.text$_ZN8CryptoPP23FilterWithBufferedInput4Put2EPKhyib[_ZN8CryptoPP23FilterWithBufferedInput4Put2EPKhyib]+0x48):
undefined reference to
`CryptoPP::FilterWithBufferedInput::PutMaybeModifiable(unsigned char*,
unsigned long long, int, bool, bool)'
/tmp/ccL1UIhb.o:test.cpp:(.text$_ZN8CryptoPP23FilterWithBufferedInput14PutModifiable2EPhyib[_ZN8CryptoPP23FilterWithBufferedInput14PutModifiable2EPhyib]+0x48):
undefined reference to
`CryptoPP::FilterWithBufferedInput::PutMaybeModifiable(unsigned char*,
unsigned long long, int, bool, bool)'
/tmp/ccL1UIhb.o:test.cpp:(.text$_ZN8CryptoPP17SimpleProxyFilterC2EPNS_22BufferedTransformationES2_[_ZN8CryptoPP17SimpleProxyFilterC2EPNS_22BufferedTransformationES2_]+0x35):
undefined reference to
`CryptoPP::ProxyFilter::ProxyFilter(CryptoPP::BufferedTransformation*,
unsigned long long, unsigned long long,
CryptoPP::BufferedTransformation*)'
[truncated]
----
Full Log: https://8n1.org/raw/12425/afb6

Is this a bug, or am I linking against libcryptopp.a the wrong way?

Thanks,
Bob

Jeffrey Walton

unread,
Dec 14, 2017, 7:53:06 AM12/14/17
to Crypto++ Users


On Wednesday, December 6, 2017 at 12:59:27 PM UTC-5, b...@cadamail.com wrote:
...

This is the sort of error I usually see when I forget to link to the library; or typo the library name.

Maybe a -v will help identify the path problem you are experiencing.

Jeff
Reply all
Reply to author
Forward
0 new messages