How to install and use just Clang-Format on Fedora 27?
Asked Answered
T

1

7

I'm trying to figure out how to install the stand alone Clang-Format tool.

I've downloaded the pre build binaries for Clang from the official download page for my OS (Fedora 27).

However I failed to figure out how to run the tool.

The documentation above says clang-format is located in clang/tools/clang-format however such path doesn't exists in the downloaded files.

I searched the entire downloaded directory for 'format' and found 'clang-format' executable in the /bin/ directory.

However when I try to run it from the terminal like so: ./clang-format

The terminal says: bash: ./clang-format: No such file or directory

(I've changed the file permissions to allow execution)

I've also looked into building clang-format from source, but I failed to find instructions how to build clang-format alone without any other clang additions.

Help would be greatly appreciated. Thank you!

Tourane answered 6/8, 2018 at 15:27 Comment(0)
M
16

Install clang-tools extra:

sudo dnf install clang-tools-extra

For Fedora < 32, you just need to install clang, which already bundles the clang-format tool.

sudo dnf install clang

And if you want to find the location of clang-format.You can use locate.

locate clang-format
Mariomariology answered 7/8, 2018 at 6:8 Comment(2)
Thank you, but shouldn't it also work when you download it from them? Clang-Format should be a stand alone tool.. Why do I need to install all of clang to use it?Tourane
@MichaelFildstein clang-format depends on the libclang-cpp.so library, I guess to reuse the C++ parser and maybe other syntactic analysis tools. That library takes a large part of the installed size of the clang-libs package, which is two orders of magnitude larger than the clang package which only packages the binaries. So, while it's possible to carve clang-format and/or libclang-cpp.so into separate packages, the space savings might not be a game changer.Sirmons

© 2022 - 2024 — McMap. All rights reserved.