Code Monkey home page Code Monkey logo

rust-c-hello's Introduction

rust-c-hello

Simple example of running C code from Rust code, based on the examples at:

  1. https://github.com/alexcrichton/gcc-rs
  2. https://users.rust-lang.org/t/linking-with-custom-c-library/637/4
  3. http://doc.crates.io/build-script.html

Building

To build it, just type cargo build. To build and run, just type cargo run.

For Windows users', you need to run it from a command line setup with the MSVS compiler environment variables. You can create a batch file named vs.bat like this:

@echo off

:: Path to your Visual Studio folder.
::
:: Examples:
::     C:\Program Files\Microsoft Visual Studio 9.0
::     F:\VisualStudio2015
set VISUAL_STUDIO_FOLDER=F:\VisualStudio2015

:: Load compilation environment
call "%VISUAL_STUDIO_FOLDER%\VC\vcvarsall.bat" x64

:: Invoke compiler with any options passed to this batch file
%*

And put it on your path variable. Therefore just call vs.bat cargo run and it would set up the MSVS environment variable and call the command cargo run to build the project.

This also allow you to call vs.bat cargo run from other shells environments like Cygwin's Mintty command line.

rust-c-hello's People

Contributors

evandrocoan avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.