I've tried 'make' and 'cmake' in my local system, it works well.
But the executable cannot run on some linux system that doesn't have libboost library.
So I need to compile a static executable.
I tried to put these in CMakeLists.txt line 72, and ran 'cmake'.
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
The leelaz executable from 3M to 27M!
It seems like everything is going well!
But when I exec it, error happened.
Segmentation fault (core dumped)
What can I do? Help me plz.
If you use the Makefile in /src, just put everything from DYNAMIC_LIBS into LIBS instead, and add -static to CFLAGS and LDFLAGS.
Additionally, look for the -march=native flag in the Makefile and remove it.
The latter might also be the reason your CMake changes didn't work, i.e. remove that flag from the CMakeLists.txt as well.
My linux system doesn't have a gpu.
So I remove "#define USE_OPENCL" in config.h , and it work well originally.
But I tried your guide to compile, a error happened.
/usr/bin/ld: cannot find -lOpenCL
I tried to remove all the opencl library in Makefile, and it compile successfully!
But when I run leelaz, same error happened.
Segmentation fault (core dumped)
What should I do?
I can reproduce this on Ubuntu 16.04. It looks like one of the used libraries doesn't like a static link.
Okay, you'll need another trick. Go back to the original Makefile, remove -march=native again, and make it read:
LIBS = -lboost_program_options
DYNAMIC_LIBS = -lpthread -lz
Remove the OpenCL reference later on.
Near the end
leelaz: $(objects)
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) $(DYNAMIC_LIBS)
to
leelaz: $(objects)
$(CXX) $(LDFLAGS) -o $@ $^ -Wl,-Bstatic $(LIBS) -Wl,-Bdynamic $(DYNAMIC_LIBS)
This statically links boost but dynamically links everything else.
Oh my god! It runs successfully!!!
Thank you really really much! You save my life!!!!
Most helpful comment
I can reproduce this on Ubuntu 16.04. It looks like one of the used libraries doesn't like a static link.
Okay, you'll need another trick. Go back to the original Makefile, remove -march=native again, and make it read:
Remove the OpenCL reference later on.
Near the end
This statically links boost but dynamically links everything else.