Giter Site home page Giter Site logo

clang-sys's Introduction

clang-sys

crates.io Travis CI AppVeyor

Rust bindings for libclang.

If you are interested in a Rust wrapper for these bindings, see clang-rs.

Supported on the stable, beta, and nightly Rust channels.

Released under the Apache License 2.0.

Supported Versions

To target a version of libclang, enable one of the following Cargo features:

If you do not enable one of these features, the API provided by libclang 3.5 will be available by default.

Dependencies

By default, this crate will attempt to link to libclang dynamically. In this case, this crate depends on the libclang shared library (libclang.so on Linux, libclang.dylib on OS X, libclang.dll on Windows). If you want to link to libclang statically instead, enable the static Cargo feature. In this case, this crate depends on the LLVM and Clang static libraries. If you don't want to link to libclang at compiletime but instead want to load it at runtime, enable the runtime Cargo feature.

These libraries can be either be installed as a part of Clang or downloaded here.

Note: This crate supports finding versioned instances of libclang.so (e.g., libclang.so.3.9 or libclang-3.9.so). In the case where there are multiple instances to choose from, this crate will prefer an unversioned instance first, then the version with the shortest and highest version. For example, the following instances of libclang.so are listed in descending order of preference:

  1. libclang.so
  2. libclang.so.4
  3. libclang.so.4.0
  4. libclang.so.3
  5. libclang.so.3.9

Note: The downloads for LLVM and Clang 3.8 and later do not include the libclang.a static library. This means you cannot link to any of these versions of libclang statically unless you build it from source.

Environment Variables

The following environment variables, if set, are used by this crate to find the required libraries and executables:

  • LLVM_CONFIG_PATH (compiletime) - provides a path to an llvm-config executable
  • LIBCLANG_PATH (compiletime) - provides a path to a directory containing a libclang shared library
  • LIBCLANG_STATIC_PATH (compiletime) - provides a path to a directory containing LLVM and Clang static libraries
  • CLANG_PATH (runtime) - provides a path to a clang executable

Linking

Dynamic

First, the libclang shared library will be searched for in the directory provided by the LIBCLANG_PATH environment variable if it was set. If this fails, the directory returned by llvm-config --libdir will be searched. Failing that, the directories in the LD_LIBRARY_PATH environment variable will be searched. If none of these approaches is successful, a list of likely directories will be searched (e.g., /usr/local/lib on Linux).

On Linux, running an executable that has been dynamically linked to libclang may require you to add a path to libclang.so to the LD_LIBRARY_PATH environment variable. The same is true on OS X, except the DYLD_LIBRARY_PATH environment variable is used instead.

On Windows, running an executable that has been dynamically linked to libclang requires that libclang.dll can be found by the executable at runtime. See here for more information.

Static

The availability of llvm-config is not optional for static linking. Ensure that an instance of this executable can be found on your system's path or set the LLVM_CONFIG_PATH environment variable. The required LLVM and Clang static libraries will be searched for in the same way as the shared library is searched for, except the LIBCLANG_STATIC_PATH environment variable is used in place of the LIBCLANG_PATH environment variable.

Runtime

The clang_sys::load function is used to load a libclang shared library for use in the thread in which it is called. The clang_sys::unload function will unload the libclang shared library. clang_sys::load searches for a libclang shared library in the same way one is searched for when linking to libclang dynamically at compiletime.

clang-sys's People

Contributors

bsteinb avatar emilio avatar gifnksm avatar jdm avatar jeandudey avatar jupp0r avatar kornelski avatar kylemayes avatar semarie avatar shinglyu avatar tamird avatar tannerrogalsky avatar tov avatar upsuper avatar yamakaky avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.