Skip to content

Instantly share code, notes, and snippets.

@farseerfc
Last active September 18, 2016 01:41
Show Gist options
  • Save farseerfc/a579c411097628315d68d9f5bc026b9f to your computer and use it in GitHub Desktop.
Save farseerfc/a579c411097628315d68d9f5bc026b9f to your computer and use it in GitHub Desktop.
extern crate rustcxx_codegen;
fn main() {
rustcxx_codegen::build("src/main.rs");
}
export CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -I/usr/lib/qt/mkspecs/linux-g++"
cargo build
[package]
name = "rustqt"
build = "build.rs"
version = "0.1.0"
authors = ["Jiachen Yang <[email protected]>"]
[dependencies]
[dependencies.rustcxx_plugin]
git = "https://github.com/google/rustcxx.git"
[build-dependencies.rustcxx_codegen]
git = "https://github.com/google/rustcxx.git"
#![feature(plugin)]
#![plugin(rustcxx_plugin)]
#[link(name = "Qt5Core")]
#[link(name = "Qt5Gui")]
#[link(name = "Qt5Widgets")]
extern {}
cxx_inline! {
#include <QApplication>
#include <QPushButton>
}
fn main() {
std::process::exit( unsafe { cxx![() -> i32{
int argc = 0;
char arg[] = "./qtdemo";
char * argv [] = {arg, 0};
QApplication app (argc, argv);
QPushButton button ("Hello world !");
button.show();
app.exec()
}]});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment