EAST icon indicating copy to clipboard operation
EAST copied to clipboard

installed on Mac but failed to compile the lanms

Open 3y3y3y opened this issue 7 years ago • 5 comments
trafficstars

I have tried makefile in lanms but I got the error:

ld: library not found for -lpython3.6m clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [adaptor.so] Error 1

tried the solution of #113 with the python3.6-dev but not working. Does anyone have any ideas to solve it?

Thanks a lot!

3y3y3y avatar Aug 17 '18 09:08 3y3y3y

you need to add ipython library

qq8057656qq avatar Jan 19 '19 11:01 qq8057656qq

I had a similar problem and used the solution here: https://github.com/ContinuumIO/anaconda-issues/issues/1761#issuecomment-315336135

In a Mac OSX Terminal I first typed:

python3-config --ldflags

This gave me:

-L/anaconda3/envs/east-text-detection/lib/python3.6/config-3.6m-darwin -lpython3.6m -ldl -framework CoreFoundation -Wl,-stack_size,1000000 -framework CoreFoundation

I copied that and then opened the Makefile in the lanms folder. Then, in the Makefile, I manually changed the entry to the LDFLAGS option to -L/anaconda3/envs/east-text-detection/lib/python3.6/config-3.6m-darwin -lpython3.6m -ldl -framework CoreFoundation i.e. everything before the -Wl flag.

Then I tried to run the demo example again python run_demo_server.py --checkpoint_path east_icdar2015_resnet_v1_50_rbox/ and the clang and make errors no longer appear.

meenaparam avatar Feb 19 '19 11:02 meenaparam

This post on Stackoverflow also deals with the problem, and associated other ones:

https://stackoverflow.com/questions/54114773/pyenv-compiling-a-module

meenaparam avatar Feb 19 '19 12:02 meenaparam

Try this:

  1. open folder "lanms",
  2. change the name of the file "adapter.pcc" to "adapter.pyd",
  3. open the file "init.py" and delete/comment line 7-8.

This works for me. Good luck :)

lidongliang-cloud avatar Apr 21 '20 02:04 lidongliang-cloud

The above solution did not work for me in then end, while it was possible to compile lanms, importing it caused a fatal error. Fatal Python error: PyThreadState_Get: no current thread.

I am using miniconda on MacOS. Interestingly, with the standard python distro on MacOS the solutions worked, but not with the conda python.

After some digging, I found some answer on SO that said we should not use python3-config --ldflags for linked compilations (because it might include this -lpython3.6m or similar which is the problem), but instead use the output from python -c "from distutils import sysconfig; print(sysconfig.get_config_var('BLDSHARED').split(' ', 1)[1]).

This worked for me in the end then (build works and import works.)

My full Makefile for conda on MacOS is linked here as well https://github.com/luksurious/UIED/blob/master/detect_text_east/lib_east/lanms/Makefile

CXXFLAGS = -I include -std=c++11 -O3 $(shell python3-config --cflags)

UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
    LDSTACK = -Wl,-stack_size,1000000 -bundle
    TMPFLAGS = $(shell python -c "from distutils import sysconfig; print(sysconfig.get_config_var('BLDSHARED').split(' ', 1)[1])")
    LDFLAGS := $(filter-out $(LDSTACK), $(TMPFLAGS))
    DEPS = lanms.h $(shell find include -type f)
else
    LDFLAGS = $(shell python3-config --ldflags)
    DEPS = lanms.h $(shell find include -xtype f)
endif

CXX_SOURCES = adaptor.cpp include/clipper/clipper.cpp

LIB_SO = adaptor.so

$(LIB_SO): $(CXX_SOURCES) $(DEPS)
	$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC

clean:
	rm -rf $(LIB_SO)

luksurious avatar Oct 16 '20 15:10 luksurious