wmd icon indicating copy to clipboard operation
wmd copied to clipboard

install error=> ld: unknown option: -shared

Open wwwxmu opened this issue 8 years ago • 1 comments

mac os high sierra 10.13 install error

Building object file 'emd.o'. -n cc -o emd.o -c emd.c -fPIC -I/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 In file included from emd.c:20: ./emd.h:22:9: warning: 'INFINITY' macro redefined [-Wmacro-redefined] #define INFINITY 1e20 ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/math.h:68:9: note: previous definition is here #define INFINITY HUGE_VALF ^ 1 warning generated.

Generating C interface swig -python emd.i

Building object file 'emd_wrap.o'. -n cc -o emd_wrap.o -c emd_wrap.c -fPIC -I/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 In file included from emd_wrap.c:3020: ./emd.h:22:9: warning: 'INFINITY' macro redefined [-Wmacro-redefined] #define INFINITY 1e20 ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/math.h:68:9: note: previous definition is here #define INFINITY HUGE_VALF ^ 1 warning generated.

Linking wrapper library '_emd.so'. -n ld -shared -o _emd.so emd.o emd_wrap.o ld: unknown option: -shared make: *** [_emd.so] Error 1 rm emd_wrap.o emd.o emd_wrap.c

wwwxmu avatar Oct 18 '17 07:10 wwwxmu

I am also working on a Mac, and had both this and then subsequently some of the other reported installation problems.

Firstly this one - replace '-shared' with '-dylib'

After that, if you have multiple python installations and use some sort of Python virtual environment (I'm using Anaconda) you'll probably still have problems, first with building, and then potentially with runtime errors (Fatal Python error: PyThreadState_Get: no current thread).

To resolve these you need to ensure that you are building the EMD module against the correct libraries for your runtime Python installation. Assuming you have your runtime python activated then changing the makefile like this should solve your issues:

...
WRAPPERS := _emd.so emd.py
INCLUDES := $(shell python2-config --includes)

CC = cc
LD = ld
LIBS := $(shell python2-config --prefix)/lib
LD_FLAGS := -L$(LIBS) $(shell python2-config --ldflags)
CFLAGS := $(shell python2-config --cflags)
CFLAGS += -fPIC

all: $(WRAPPERS)

_%.so: %.o %_wrap.o
	@echo ">>> Linking wrapper library '$(@)'."
	@echo -n "    "
	$(LD) $(LD_LIBS) $(LD_FLAGS) -dylib -o $@ $^
	@echo

%.o: %.c
	@echo ">>> Building object file '$(@)'."
	@echo -n "    "
	$(CC) -o $@ -c $< $(CFLAGS) $(INCLUDES) $(LIBS)
	@echo
...

sdraper-CS avatar Apr 05 '18 19:04 sdraper-CS