Open charlotteVDD opened 5 years ago
Hello, you might want to check your gcc version.
sure...
Actually, I doubt I have a gcc...
Could this fasttext issue be relevant? https://github.com/facebookresearch/fastText/issues/386#issuecomment-354189736
Yes the problem seems to be close to that but in my case it seems that it is a bit different since the error comes from the sent2vec.cpp file. I installed fastText as recommended from the readme... anaconda version is 4.5
I don t have a mac to test this, but maybe try adding this code in setup.py
:
def has_flag(compiler, flags):
"""Return a boolean indicating whether a flag name is supported on
the specified compiler.
"""
import tempfile
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:
f.write('int main (int argc, char **argv) { return 0; }')
try:
compiler.compile([f.name], extra_postargs=flags)
except setuptools.distutils.errors.CompileError:
return False
return True
def cpp_flag(compiler):
"""Return the -std=c++[0x/11/14] compiler flag.
The c++14 is preferred over c++0x/11 (when it is available).
"""
standards = ['-std=c++14', '-std=c++11', '-std=c++0x']
for standard in standards:
if has_flag(compiler, [standard]):
return standard
raise RuntimeError(
'Unsupported compiler -- at least C++0x support '
'is needed!'
)
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc'],
'unix': [],
}
def build_extensions(self):
if sys.platform == 'darwin':
all_flags = ['-stdlib=libc++', '-mmacosx-version-min=10.7']
if has_flag(self.compiler, [all_flags[0]]):
self.c_opts['unix'] += [all_flags[0]]
elif has_flag(self.compiler, all_flags):
self.c_opts['unix'] += all_flags
else:
raise RuntimeError(
'libc++ is needed! Failed to compile with {} and {}.'.
format(" ".join(all_flags), all_flags[0])
)
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, ['-fvisibility=hidden']):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append(
'/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()
)
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
And replace the call to setup by:
setup(
name='sent2vec',
ext_modules=cythonize(ext),
cmdclass={'build_ext': BuildExt}
)
The extra code is coming from the setup.py
of the fasttext
library, it seems they fixed the compilation on mac already. I have no clue if this is going to work. Let me know.
Yes ! it worked !! thanks a lot ;)
This worked for me to a point. I'm now getting -lrt
issue. I removed it from the Makefile
, but it is being used somewhere. Any ideas how to get rid of it?
creating build/lib.macosx-10.7-x86_64-3.6
g++ -bundle -undefined dynamic_lookup -L/anaconda2/envs/py36/lib -arch x86_64 -L/anaconda2/envs/py36/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/src/sent2vec.o build/temp.macosx-10.7-x86_64-3.6/src/fasttext.o build/temp.macosx-10.7-x86_64-3.6/src/args.o build/temp.macosx-10.7-x86_64-3.6/src/dictionary.o build/temp.macosx-10.7-x86_64-3.6/src/matrix.o build/temp.macosx-10.7-x86_64-3.6/src/shmem_matrix.o build/temp.macosx-10.7-x86_64-3.6/src/qmatrix.o build/temp.macosx-10.7-x86_64-3.6/src/model.o build/temp.macosx-10.7-x86_64-3.6/src/real.o build/temp.macosx-10.7-x86_64-3.6/src/utils.o build/temp.macosx-10.7-x86_64-3.6/src/vector.o build/temp.macosx-10.7-x86_64-3.6/src/real.o build/temp.macosx-10.7-x86_64-3.6/src/productquantizer.o -lrt -o build/lib.macosx-10.7-x86_64-3.6/sent2vec.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
When I try to compile the library as Setup & Requirements suggests by running make command, errors pop up as below: c++ -pthread -std=c++0x -O3 -funroll-loops args.o dictionary.o productquantizer.o matrix.o shmem_matrix.o qmatrix.o vector.o model.o utils.o fasttext.o src/main.cc -o fasttext -lrt ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [fasttext] Error 1 how to fix on macbook
Do you still have the same error? Or are you able to install it now?
I was receiving the following fatal error on Mac:
src/sent2vec.cpp:669:10: fatal error: 'ios' file not found
It got resolved by adding -std=libc++
to both compile-options and linker-options as shown in the below link:
https://stackoverflow.com/questions/53809584/issues-about-installing-pcl-in-my-computer
Hello !
while installing, I ran python setup.py build_ext I got this answer
installation of fastest did not make any trouble ...
indeed the complete answer is
any idea ? thank you for your answers ;)