cmake installer for Mac fails to create /usr/bin s

2019-03-09 11:46发布

问题:

Try to install CMake cmake-2.8.12.2-Darwin64-universal.dmg on OS X 10.9.3 I removed the old version from Application folder and delete ccmake, cmake, cmake-gui etc in usr/bin. But get "Failed create symlink installation may be incomplete: /usr/bin/cpack" and other error messages.

Please let me know if any suggestion or question.

Thank you for precious time on my question.

回答1:

This tends to happen to me as well from time to time.

The problem is basically that the symlinks from the previous installation are not cleaned up when removing CMake from Applications and now the installer has trouble updating them to the new version.

The easiest fix here is to manually remove those links from /usr/bin and re-run the installer. IIRC it's at least cmake, ccmake, cmake-gui, cpack and ctest that need removing. Best way is to do a ls -l /usr/bin from the console and grep for all the links pointing to the old CMake installation directory.



回答2:

CMake 3.0 does not seem to come with an installer any longer. So I ran into a similar issue. Like @ComicSansMS said you need to first remove the symlinks using sudo rm. Then you can run the gui with sudo /Applications/CMake.app/Contents/MacOS/CMake and use the Tools -> Install For Command Line Use menu item.

From some new 3.x version you have to use this command to create symlinks:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

Note option in menu now gives only this instruction and other possible choices.



回答3:

As said earlier, launch the GUI in sudo mode. Open a terminal and type:

sudo /Applications/CMake.app/Contents/MacOS/CMake

then in the GUI, go to Tools menu and Install For Command Line Use and press the Install Command Line Links button. The terminal will show:

ln -s [/Applications/CMake.app/Contents/bin/ccmake] [/usr/bin/ccmake]
ln -s [/Applications/CMake.app/Contents/bin/cmake] [/usr/bin/cmake]
ln -s [/Applications/CMake.app/Contents/bin/cmake-gui] [/usr/bin/cmake-gui]
ln -s [/Applications/CMake.app/Contents/bin/cmakexbuild] [/usr/bin/cmakexbuild]
ln -s [/Applications/CMake.app/Contents/bin/cpack] [/usr/bin/cpack]
ln -s [/Applications/CMake.app/Contents/bin/ctest] [/usr/bin/ctest]

and here you are. Tested with cmake-3.1.0-rc2.



回答4:

In the latest versions the install procedure is simple, in the terminal simply type:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

And the soft links will be automatically generated.

Tested with cmake version 3.3.2 and cmake version 3.8.0


If you fear you might have remaining links from a previous version you can remove them before installing the new version:

cd /usr/bin; sudo rm ccmake cmake cmake-gui cmakexbuild cpack ctest

Otherwise for older versions you should start the application with an account with admin privileges for the install to work. i.e.:

sudo /Applications/CMake.app/Contents/MacOS/CMake


回答5:

There is a option in

Cmake GUI->Tools->How to install for command line use

which shows options

One may add CMake to the PATH:

 PATH="/Applications/CMake.app/Contents/bin":"$PATH"

Or, to install symlinks to '/usr/local/bin', run:

 sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

Or, to install symlinks to another directory, run:

 sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/path/to/bin

In which first option worked for me.



回答6:

In the CMake 3.3.0 there is no longer the option Install For Command Line. Below is how I did it.

I've downloaded the dmg file and copied to Applications folder. But I had to add the path to the binary to the PATH environment variable. This is the complete step-by-step.

  1. Download CMake dmg from official website (http://www.cmake.org);

  2. Open the dmg file. Copy the CMake executable to the Applications folder;

  3. Open a terminal and type "cd ~" (to go to your home folder);

  4. Open the file .bash_profile (if it does not exist, create it with "touch .bash_profile");

  5. Inside .bash_profile file, insert the following line:

export PATH="/Applications/CMake.app/Contents/bin/:$PATH"

(This will add the binary of CMake to yout PATH variable)

  1. Save the .bash_profile file and exit;

  2. Back to the terminal, type "source .bash_profile", to update the PATH variable.;

  3. Ready to go! Try to compile again :)

The good part of adding it to PATH is that it will work every time you restart your computer.



回答7:

Opening the Applications folder in a terminal

cd /
cd Applications/

then doing:

sudo bash
CMake.app/Contents/bin/cmake-gui

Then run from the CMake GUI: "Tools->Install For Command Line Use"

works OK for me.



回答8:

If you want to install on OSX 10.11 it needs to be installed to /usr/local/bin ( just /usr/bin will not work! ). I couldn't get that to work with the cmake I had installed (3.2.1). After downloading the latest version (3.6.1) and using this commandline it worked. No need to go to the gui and click on 'install commandline tools', it just does it instantly.

note: it might also work without specifying /usr/local/bin on cmake-3.6.1 - haven't tested that.

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/usr/local/bin


回答9:

very simple, install the .dmg file then open,

tools->How to install for Command line use

you can find:

One may add CMake to the PATH:

PATH="/Applications/CMake.app/Contents/bin":"$PATH"

Or, to install symlinks to '/usr/local/bin', run:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

Or, to install symlinks to another directory, run:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/path/to/bin



回答10:

Try use sudo start cmake-gui, and choose folder to /usr/local/bin instead the default /usr/bin when install command line I was success