crosscat icon indicating copy to clipboard operation
crosscat copied to clipboard

Building for Anaconda on OS X requires extra linker flags

Open tibbetts opened this issue 9 years ago • 5 comments

Requires extra_link_args = ["-stdlib=libstdc++","-mmacosx-version-min=10.6"],

LDFLAGS isn't respected, not sure the right way to detect when this is needed.

tibbetts avatar Sep 18 '15 21:09 tibbetts

What goes wrong if you don't change the stdlib or if you omit the macosx-version-min?

riastradh-probcomp avatar Sep 18 '15 21:09 riastradh-probcomp

Build failure:

g++ -bundle -undefined dynamic_lookup -L/Users/tibbetts/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/crosscat/cython_code/CyclicComponentModel.o build/temp.macosx-10.5-x86_64-2.7/cpp_code/src/utils.o build/temp.macosx-10.5-x86_64-2.7/cpp_code/src/numerics.o build/temp.macosx-10.5-x86_64-2.7/cpp_code/src/RandomNumberGenerator.o build/temp.macosx-10.5-x86_64-2.7/cpp_code/src/ComponentModel.o build/temp.macosx-10.5-x86_64-2.7/cpp_code/src/CyclicComponentModel.o -L/Users/tibbetts/anaconda/lib -o build/lib.macosx-10.5-x86_64-2.7/crosscat/cython_code/CyclicComponentModel.so
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1

----------------------------------------
Command "/Users/tibbetts/anaconda/bin/python -c "import setuptools, tokenize;__file__='/var/folders/h9/8d2yv2ln0gq74mp5mffdw8qw0000gn/T/pip-6CaCIe-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/h9/8d2yv2ln0gq74mp5mffdw8qw0000gn/T/pip-pFbKkb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /var/folders/h9/8d2yv2ln0gq74mp5mffdw8qw0000gn/T/pip-6CaCIe-build

tibbetts avatar Sep 18 '15 21:09 tibbetts

Is that without -stdlib=libstdc++, or is that without -mmacosx-version-min=10.6?

riastradh-probcomp avatar Sep 18 '15 21:09 riastradh-probcomp

I just tried setting LDFLAGS and it took effect:

% LDFLAGS=-wotsit python setup.py build
...
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -wotsit build/temp.linux-x86_64-2.7/crosscat/cython_code/CyclicComponentModel.o build/temp.linux-x86_64-2.7/cpp_code/src/utils.o build/temp.linux-x86_64-2.7/cpp_code/src/numerics.o build/temp.linux-x86_64-2.7/cpp_code/src/RandomNumberGenerator.o build/temp.linux-x86_64-2.7/cpp_code/src/ComponentModel.o build/temp.linux-x86_64-2.7/cpp_code/src/CyclicComponentModel.o -o build/lib.linux-x86_64-2.7/crosscat/cython_code/CyclicComponentModel.so
c++: error: unrecognized command line option ‘-wotsit’
error: command 'c++' failed with exit status 1

riastradh-probcomp avatar Sep 18 '15 21:09 riastradh-probcomp

I stand corrected, the following line builds successfully:

LDFLAGS="-stdlib=libstdc++ -mmacosx-version-min=10.6" pip install git+ssh://[email protected]/probcomp/crosscat

tibbetts avatar Sep 19 '15 00:09 tibbetts