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

fatal error while installing #48

Open
charlotteVDD opened this issue Oct 1, 2018 · 10 comments
Open

fatal error while installing #48

charlotteVDD opened this issue Oct 1, 2018 · 10 comments

Comments

@charlotteVDD
Copy link

Hello !

while installing, I ran
python setup.py build_ext
I got this answer

image

installation of fastest did not make any trouble ...

indeed the complete answer is

image

any idea ?
thank you for your answers ;)

@mpagli
Copy link
Member

mpagli commented Oct 1, 2018

Hello, you might want to check your gcc version.

@charlotteVDD
Copy link
Author

sure...
image
Actually, I doubt I have a gcc...

@mpagli
Copy link
Member

mpagli commented Oct 1, 2018

Could this fasttext issue be relevant? facebookresearch/fastText#386 (comment)

@charlotteVDD
Copy link
Author

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

@mpagli
Copy link
Member

mpagli commented Oct 3, 2018

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.

@charlotteVDD
Copy link
Author

Yes ! it worked !!
thanks a lot ;)

@yasonk
Copy link

yasonk commented Mar 7, 2019

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

@hoi-nx
Copy link

hoi-nx commented Mar 20, 2019

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

@guptaprkhr
Copy link
Contributor

Do you still have the same error? Or are you able to install it now?

@kgarg8
Copy link

kgarg8 commented Jun 29, 2021

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

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

6 participants