问题
I'm trying to installing Crypto++ 5.6.2 on my Mac. When I run
make -j4 libcryptopp.a"
I get the following error:
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make: *** [libcryptopp.a] Error 1
Can someone please help me with this?
回答1:
Can someone please help me with this?
There's a couple of things you can do to make this easier.
First, open GNUmake and add fPIC
on line 1:
CXXFLAGS = -DNDEBUG -g -O2 -fPIC
Second, open GNUmake and drop "version" from the Clang detection logic on line 18:
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
Third, open GNUmake and drop GAS check from around the Darwin flags around line 38. You want the Darwin check standing alone, without the ifeq ($(GAS219_OR_LATER),0)
check.
ifeq ($(UNAME),Darwin)
CXXFLAGS += -arch x86_64 -arch i386
else
CXXFLAGS += -march=native
endif
Fourth, open GNUmake and add the following after the Darwin flags around line 45:
ifneq ($(CLANG_COMPILER),0)
CXXFLAGS += -Wno-tautological-compare -Wno-unused-value
endif
With the makefile tweaked:
# Make the static lib, shared object, and test program
cd cryptopp
make static dynamic cryptest.exe
After make completes:
# Run the test program
cd cryptopp
./cryptest.exe v
After the validation suit completes successfully:
# Install into /usr/local
cd cryptopp
sudo make install PREFIX=/usr/local
OS X can be a real bear. It can be a bear because it silently ignores LD_PRELOAD
(it uses DYLD_LIBRARY_PATH
instead, see dyld(3) man pages); it silently drops -Wl,rpath
; it silently drops -Bstatic
; and it always links to a shared object if available. It will link to the dynamic lib even on iOS, where its forbidden!
On OS X, It would behoove you you fully specify the static archive, and not use -l
and -L
. That is, use the following (this is from one of my test programs I use on OS X):
g++ -DDEBUG=1 -g3 -O0 -Wall -Wextra -Wno-unused-parameter \
-I/usr/local/include/cryptopp \
cryptopp-test.cpp -o cryptopp-test.exe \
/usr/local/lib/libcryptopp.a
Its OK to fully specify libcryptopp.a
. An archive is just a collection of object files, and you can specify object files for linking on the command line.
Here's a Pastebin of the GNUmakefile I use: Crypto++ modified makefile for OS X and mobile.
EDIT (June 2015): Crypto++ is migrating away from Sourceforge to GitHub. Most of the changes discussed above have been Incorporated into the makefile.
来源:https://stackoverflow.com/questions/25728659/installing-crypto-5-6-2-on-mac-os-x