Fasttext: build error: clang: error: linker command failed with exit code 1

Created on 24 Oct 2018  路  7Comments  路  Source: facebookresearch/fastText

I cannot build fasttext with pip install .
The "python setup.py install" command also is not building.

Has anyone run into this error when building the latest version of fastText?
I had previously had it built on my machine, and then removed it.
Upon reinstallation by cloning the latest version, I'm getting the following:

with
MacOS Mojave
MacBook Pro

Compiler info:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin18.0.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Relevant traceback:

 creating build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/fasttext.cpp -o build/temp.macosx-10.7-x86_64-3.6/fasttext/fasttext.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/interface.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/interface.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    fasttext/interface.cc:255:39: warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead. [-Wdeprecated-declarations]
        std::string temp_file_name = std::tmpnam(nullptr);
                                          ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/stdio.h:186:1: note: 'tmpnam' has been explicitly marked deprecated here
    __deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.")
    ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sys/cdefs.h:180:48: note: expanded from macro '__deprecated_msg'
            #define __deprecated_msg(_msg) __attribute__((deprecated(_msg)))
                                                          ^
    1 warning generated.
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/args.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/args.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/dictionary.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/dictionary.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    fasttext/cpp/src/dictionary.cc:126:52: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        for (size_t j = i, n = 1; j < word.size() && n <= args_->maxn; n++) {
                                                     ~ ^  ~~~~~~~~~~~
    fasttext/cpp/src/dictionary.cc:131:13: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
          if (n >= args_->minn && !(n == 1 && (i == 0 || j == word.size()))) {
              ~ ^  ~~~~~~~~~~~
    fasttext/cpp/src/dictionary.cc:140:24: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
      for (size_t i = 0; i < size_; i++) {
                         ~ ^ ~~~~~
    fasttext/cpp/src/dictionary.cc:226:24: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
      for (size_t i = 0; i < size_; i++) {
                         ~ ^ ~~~~~
    4 warnings generated.
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/matrix.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/matrix.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/model.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/model.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    fasttext/cpp/src/model.cc:74:25: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'std::__1::vector<int, std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
      for (int32_t i = 0; i < pathToRoot.size(); i++) {
                          ~ ^ ~~~~~~~~~~~~~~~~~
    fasttext/cpp/src/model.cc:148:21: warning: comparison of integers of different signs: 'std::__1::vector<std::__1::pair<float, int>, std::__1::allocator<std::__1::pair<float, int> > >::size_type' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
        if (heap.size() == k && log(output[i]) < heap.front().first) {
            ~~~~~~~~~~~ ^  ~
    fasttext/cpp/src/model.cc:153:21: warning: comparison of integers of different signs: 'std::__1::vector<std::__1::pair<float, int>, std::__1::allocator<std::__1::pair<float, int> > >::size_type' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
        if (heap.size() > k) {
            ~~~~~~~~~~~ ^ ~
    fasttext/cpp/src/model.cc:163:19: warning: comparison of integers of different signs: 'std::__1::vector<std::__1::pair<float, int>, std::__1::allocator<std::__1::pair<float, int> > >::size_type' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
      if (heap.size() == k && score < heap.front().first) {
          ~~~~~~~~~~~ ^  ~
    fasttext/cpp/src/model.cc:170:21: warning: comparison of integers of different signs: 'std::__1::vector<std::__1::pair<float, int>, std::__1::allocator<std::__1::pair<float, int> > >::size_type' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
        if (heap.size() > k) {
            ~~~~~~~~~~~ ^ ~
    5 warnings generated.
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/utils.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/utils.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/fasttext.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/fasttext.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    fasttext/cpp/src/fasttext.cc:119:25: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'std::__1::vector<int, std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
      for (int32_t w = 0; w < line.size(); w++) {
                          ~ ^ ~~~~~~~~~~~
    fasttext/cpp/src/fasttext.cc:123:41: warning: comparison of integers of different signs: 'int' and 'std::__1::vector<int, std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
          if (c != 0 && w + c >= 0 && w + c < line.size()) {
                                      ~~~~~ ^ ~~~~~~~~~~~
    fasttext/cpp/src/fasttext.cc:135:25: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'std::__1::vector<int, std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
      for (int32_t w = 0; w < line.size(); w++) {
                          ~ ^ ~~~~~~~~~~~
    fasttext/cpp/src/fasttext.cc:139:41: warning: comparison of integers of different signs: 'int' and 'std::__1::vector<int, std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
          if (c != 0 && w + c >= 0 && w + c < line.size()) {
                                      ~~~~~ ^ ~~~~~~~~~~~
    fasttext/cpp/src/fasttext.cc:300:24: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int64_t' (aka 'long long') [-Wsign-compare]
      for (size_t i = 0; i < n; i++) {
                         ~ ^ ~
    fasttext/cpp/src/fasttext.cc:305:26: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int64_t' (aka 'long long') [-Wsign-compare]
        for (size_t j = 0; j < dim; j++) {
                           ~ ^ ~~~
    fasttext/cpp/src/fasttext.cc:315:24: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int64_t' (aka 'long long') [-Wsign-compare]
      for (size_t i = 0; i < n; i++) {
                         ~ ^ ~
    fasttext/cpp/src/fasttext.cc:318:26: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int64_t' (aka 'long long') [-Wsign-compare]
        for (size_t j = 0; j < dim; j++) {
                           ~ ^ ~~~
    8 warnings generated.
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/vector.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/vector.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/SampleName/anaconda3/include -arch x86_64 -I/Users/SampleName/anaconda3/include -arch x86_64 -I./fasttext -I/Users/SampleName/anaconda3/include/python3.6m -c fasttext/cpp/src/main.cc -o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/main.o -O3 -pthread -funroll-loops -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7
    g++ -bundle -undefined dynamic_lookup -L/Users/SampleName/anaconda3/lib -arch x86_64 -L/Users/SampleName/anaconda3/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/fasttext/fasttext.o build/temp.macosx-10.7-x86_64-3.6/fasttext/interface.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/args.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/dictionary.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/matrix.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/model.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/utils.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/fasttext.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/vector.o build/temp.macosx-10.7-x86_64-3.6/fasttext/cpp/src/main.o -o build/lib.macosx-10.7-x86_64-3.6/fasttext/fasttext.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 -lstdc++
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'g++' failed with exit status 1```
    ----------------------------------------
Command "/Users/SampleName/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/2x/c0mhw9716bj8zt68qvdk3dg40000gp/T/pip-install-n4pcw1z8/fasttext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/2x/c0mhw9716bj8zt68qvdk3dg40000gp/T/pip-record-4z_tjdv2/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/2x/c0mhw9716bj8zt68qvdk3dg40000gp/T/pip-install-n4pcw1z8/fasttext/
Build Python

Most helpful comment

export MACOSX_DEPLOYMENT_TARGET=10.9

All 7 comments

export MACOSX_DEPLOYMENT_TARGET=10.9

python setup.py install worked for me after trying export MACOSX_DEPLOYMENT_TARGET=10.9.

thx! that worked after trying "export MACOSX_DEPLOYMENT_TARGET=10.9"

export MACOSX_DEPLOYMENT_TARGET=10.9

It works for me!
macOS 10.14

why is it useful for "
export MACOSX_DEPLOYMENT_TARGET=10.9"

Hi,
Can you check if ebf807422ace063cf27cf841a32e951f5a5b669d fixes the issue (without having to set the env. variable manually) ?

Thank you for reporting!
Onur

Hi,
I will close this issue here. Please feel free to re-open it if the commit is not enough to fix the issue.

Best regards,
Onur

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pengyu picture pengyu  路  3Comments

hughbzhang picture hughbzhang  路  3Comments

AhmedIdr picture AhmedIdr  路  3Comments

loretoparisi picture loretoparisi  路  3Comments

loretoparisi picture loretoparisi  路  3Comments