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

libtool: unrecognized option -static when building #2341

Closed
brycekahle opened this issue Aug 10, 2015 · 23 comments
Closed

libtool: unrecognized option -static when building #2341

brycekahle opened this issue Aug 10, 2015 · 23 comments
Labels
build Issues and PRs related to build files or the CI. macos Issues and PRs related to the macOS platform / OSX.

Comments

@brycekahle
Copy link
Contributor

Fresh clone and first attempt at building io.js, After running ./configure and make, I encounter this error:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C out BUILDTYPE=Release V=1
  rm -f /Users/bwkahle/git/io.js/out/Release/libgtest.a && ./gyp-mac-tool filter-libtool libtool  -static -o /Users/bwkahle/git/io.js/out/Release/libgtest.a /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-death-test.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-filepath.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-port.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-printers.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-test-part.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-typed-test.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest_main.o
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[1]: *** [/Users/bwkahle/git/io.js/out/Release/libgtest.a] Error 1
make: *** [iojs] Error 2

Here is version information for my build environment:

gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
python --version
Python 2.7.10

Any help is much appreciated. Thanks!

@brendanashworth brendanashworth added build Issues and PRs related to build files or the CI. macos Issues and PRs related to the macOS platform / OSX. labels Aug 10, 2015
@bnoordhuis
Copy link
Member

I speculate that you have a libtool from e.g. homebrew on your path somewhere. which libtool should print /usr/bin/libtool and libtool --version should probably be 2.4.2.

@brycekahle
Copy link
Contributor Author

Thanks for the reply! You are a correct, it was libtool from chefdk at /opt/chefdk/embedded/bin/libtool.

@jrgleason
Copy link

What happens if you are at 2.4.6? Do we need to downgrade?

@wm-oci
Copy link

wm-oci commented Jun 28, 2018

It seems odd that a libtool minor update (from 2.4.2 to 2.4.6) should be a breaking change. This is also causing nodejs to fail on install, specifically to install node-gyp during node-gyp's make step.

macOS High Sierra
libtool 2.4.6
GNU Make 3.81
node 10.5.0
node-gyp -v v3.6.2

Try 'libtool --help' for more information.
libtool:   error: unrecognised option: '-static'
make: *** [Release/sass.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/you/project/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/you/project/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/you/project/node_modules/node-sass
gyp ERR! node -v v10.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1

@zomglings
Copy link

Any updates on this issue? I had to do some path gymnastics to get around this on my mac.

OS: macOS High Sierra
libtool 2.4.6 (installed with MacPorts)
node 9.11.2

@zomglings
Copy link

Wit MacPorts, this worked for me:

sudo port deactivate libtool
npm install
sudo port activate libtool

@Alphatone
Copy link

Had this error with my local MAMP setup.
OS: macOS High Sierra 13.6
node: 10.12.0 / 6.11.14 (tried both)

Does not work:
PATH=/Applications/MAMP/Library/bin/:$PATH

Does work:
PATH=/usr/local/bin:$PATH

I switched back and forth between the MAMP path and the usr/local/bin, works now with the MAMP path as well. If anyone can tell me why, I would highly appreciate it.

@zk4
Copy link

zk4 commented Jan 22, 2019

try this

brew unlink libtool
rm -rf /usr/local/bin/libtool
which libtool

point to /usr/bin/libtool

@wuliupo
Copy link

wuliupo commented Jan 26, 2019

try this

brew unlink libtool
rm -rf /usr/local/bin/libtool
which libtool

point to /usr/bin/libtool

Thanks @zk4 . it works for me

@benchuk
Copy link

benchuk commented Feb 24, 2019

Thanks @zk4 . it works for me as well!

@bosporos
Copy link

bosporos commented Mar 1, 2019

Since I use neither macports or homebrew (I do my builds straight from source), I had to cook up something a little more homebrew; the end-product you see before you.

A pair of liners that worked for me (should be done in the same shell context, tho, because it relies on the variable $CHANGED_FILES to keep the information; you could rework it to save to a file, too):

  1. Renames all libtools in $PATH to libtool_hidden (except for /usr/bin/libtool), and dumps the paths to the libtools (pre-change) to a variable named $CHANGED_FILES. Run before compiling node
CHANGED_FILES=''; while [[ `which libtool` != '/usr/bin/libtool' ]] ; do ORIGINAL=`which libtool`; CHANGED_FILES="$CHANGED_FILES $ORIGINAL"; mv `which libtool` `which libtool`_hidden ; done
  1. Moves the libtool_hidden files back to where they were originally:
for file in $CHANGED_FILES ; do mv "$(dirname $file)/libtool_hidden" $file ; done

@matthewbauer
Copy link

matthewbauer commented May 3, 2019

@brycekahle Can this be reopened? This is still a valid issue from what I can tell. node-gyp should provide a fallback in the case where GNU libtool is in your PATH. In some cases GNU libtool needs to be in your PATH based on requirements from other packages.

@matthewbauer
Copy link

Actually this looks like it's more of a problem in chromium gyp. Unfortunately they don't have an issue tracker ☹️

@bnoordhuis
Copy link
Member

There's no need to reopen, it's working as expected. If you override the system libtool with something else, you had better make sure it's compatible. Ditto cc, ar, ld, etc.

@matthewbauer
Copy link

matthewbauer commented May 5, 2019

The problem is other tools expect libtool to be the GNU one. I guess you could say it’s an issue with those tools but it is much more common for the GNU libtool to be used and not the very obscure NeXTSTEP one. This kind of thing probably wouldn’t come up much in chromium’s use case, but is very very common when building multi language projects that include node bindings.

I think this can be fixed very easily by falling back to ar rcs when libtool is the GNU version. I’m willing to make a patch for this but would like the issue to be accepted as valid first.

@bnoordhuis
Copy link
Member

very obscure

It's the platform libtool. That's the opposite of obscure, it's the default.

GYP does quite a bit of processing around libtool so I'm not inclined to accept patches that try to go on when it's not the expected version, that probably creates more issues down the road than it fixes, probably more subtle ones too.

A patch that hard-codes the path to /usr/bin/libtool might be acceptable.

@chanduthedev
Copy link

try this

brew unlink libtool
rm -rf /usr/local/bin/libtool
which libtool

point to /usr/bin/libtool

Thanks. It worked for me.

@yuangu
Copy link

yuangu commented Jan 30, 2020

Thanks @zk4 . it works for me as well!

@purejgleason
Copy link

purejgleason commented Aug 21, 2021

So wait it is 2021 and this is still an issue? I just tried today with 2.4.6 and got the same

Can I regenerate the configure or something to get it to work with the GNU version?

@grasmash
Copy link

I had MAMP installed and MAMP binaries in my $PATH, including libtool:

$ which libtool
/Applications/MAMP/Library/bin/libtool

Removing that fixed the issue.

@stephanmg
Copy link

It seems odd that a libtool minor update (from 2.4.2 to 2.4.6) should be a breaking change. This is also causing nodejs to fail on install, specifically to install node-gyp during node-gyp's make step.

macOS High Sierra libtool 2.4.6 GNU Make 3.81 node 10.5.0 node-gyp -v v3.6.2

Try 'libtool --help' for more information.
libtool:   error: unrecognised option: '-static'
make: *** [Release/sass.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/you/project/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/you/project/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/you/project/node_modules/node-sass
gyp ERR! node -v v10.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1

seems to be the case for me from 2.4.6_13 to 2.4.7_0 as well, deactivating libtool with macports works.

@linonetwo
Copy link

linonetwo commented Jun 7, 2023

which libtool
/usr/bin/libtool

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `-' in: --version
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]

libtool --help
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `-' in: --help
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
Preparing native dependencies: 0 / 1
  › node-gyp failed to rebuild '/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3'
◼ Running generateAssets hook

›   TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
  ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
  TOUCH Release/obj.target/deps/locate_sqlite3.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  Usage: /opt/anaconda3/bin/libtool [OPTION]... [MODE-ARG]...
  Try 'libtool --help' for more information.
  libtool:   error: unrecognised option: '-static'
  make: *** [Release/sqlite3.a] Error 1
  rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
  Error: `make` failed with exit code: 2
  at ChildProcess.onExit (/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/.pnpm/[email protected][email protected]/node_modules/node-gyp/lib/build.js:203:23)
  at ChildProcess.emit (node:events:511:28)
  at ChildProcess._handle.onexit (node:internal/child_process:293:12)

An unhandled rejection has occurred inside Forge:
Error: node-gyp failed to rebuild '/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3'
at ChildProcess.<anonymous> (/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/node_modules/.pnpm/@[email protected][email protected]/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:118:24)
    at ChildProcess.emit (node:events:511:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12)
 ELIFECYCLE  Command failed with exit code 1.

#2341 (comment) is not working


After uninstall anaconda3 and restart Mac, it still output the something, and try to use /opt/anaconda3/bin/libtool


manually run node_modules/.bin/electron-rebuild -f -w better-sqlite3 works.

nicholas-ochoa/OpenSC2K#33 (comment)

@BWStearns
Copy link

For me uninstalling libtool via brew worked. which libtool should return /usr/bin/libtool (if you're having the same issue as me)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. macos Issues and PRs related to the macOS platform / OSX.
Projects
None yet
Development

No branches or pull requests