Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install error=> ld: unknown option: -shared #22

Open
wwwxmu opened this issue Oct 18, 2017 · 1 comment
Open

install error=> ld: unknown option: -shared #22

wwwxmu opened this issue Oct 18, 2017 · 1 comment

Comments

@wwwxmu
Copy link

wwwxmu commented Oct 18, 2017

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

@sdraper-CS
Copy link

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
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants