Last active
September 18, 2016 01:41
-
-
Save farseerfc/a579c411097628315d68d9f5bc026b9f to your computer and use it in GitHub Desktop.
Qt Hello World in rust with https://github.com/google/rustcxx http://i.imgur.com/wq2ebvA.png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rustcxx_codegen; | |
fn main() { | |
rustcxx_codegen::build("src/main.rs"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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