I am playing with perl6 version which built on MoarVM on windows. I created some perl6 file and want to compile it to exe. I tried the following:
perl6 --target=MAST r.pl>r
Now I want to compile the r to executable
I found this link which talk about how to that using Parrot but I am using MoarVM target: http://perlgeek.de/blog-en/perl-6/my-first-executable.writeback
my question how can i compile MoarvVM targeted file to windows executable ?
Unfortunately, the answer is to target JVM and one of the many nice tools for turning a JAR into an executable. MoarVM doesn't have that tooling at this point (and given the lack of current overlap between perl6 hackers and Windows users, probably won't for some time).
One of the things that attracted me to the language, was that it was supposed to be compilable, I thought "sure, it would build exe files for me", unfortunately, it does not (last I checked).
compile:
perl6 --target=mbc --output=test.moarvm -e 'say 42'
run:
perl6 -e 'CompUnit::Loader.load-precompilation-file("test.moarvm".IO)'
However, you can compile the program t the intermediate moarvm machine, do KEEP IN MIND this is not porable, so you have to recompile on each target.
I think this code was legated to me by somebody that really knew perl6 on the irc channel, I don't understand how it works, though.
I advise if you need a compiled language, to wait for real support from the compiler guys or simply to use something like rust or golang (that is what I ended up using, I'm happy).
I know rust doesn't have all the "bells and whistles" that Perl6 has, but it gets the job done...
Related
When I install rakudo from source:
$ git clone git#github.com:rakudo/rakudo.git
$ cd rakudo
$ perl Configure.pl --gen-moar --gen-nqp --backends=moar
$ make
$ make install
it generates the following files in ./install/bin:
$ ls -1 install/bin
moar
nqp
nqp-m
perl6
perl6-debug
perl6-debug-m
perl6-gdb-m
perl6-lldb-m
perl6-m
perl6-valgrind-m
raku
raku-debug
rakudo
rakudo-debug
rakudo-debug-m
rakudo-gdb-m
rakudo-lldb-m
rakudo-m
rakudo-valgrind-m
I know that raku, rakudo, and perl6 are the the commands used to run a .raku script, but what are the other commands and how can I use them?
moar is the vm (not very useful without a bytecode file)
nqp is for NQP (Not Quite Perl6). Which is a small subset of Raku that is faster / easier to optimize. (No = op for example)
It is the bootstrap compiler for Rakudo.
For the others like rakudo-m
*-m means on MoarVM
*-j means on JVM (not installed here)
*-js means on JavaScript (not installed here)
*-debug means, use the version with debugging information
*-gdb means use the version with GNU Debugger information
*-lldb means use the version with LLDB debugging information
*-valgrind means use the Valgrind instrumentation framework (find memory leaks)
So then rakudo-valgrind-m means use Rakudo compiler with Valgrind instrumentation on MoarVM.
About the only ones I would use is rakudo-m, and rakudo-j or rakudo-js, and that is only if I had more than just the MoarVM version installed.
Mainly the rest are for people that are working on Rakudo/NQP/MoarVM projects themselves.
This question may seem stupid to you guys, but I am in a situation where I have no access to command line, and I need a version of g++ on my computer so I can compile my c++ code.
I looked on the GNU repository, and I have NO idea how to build and also install the environment.
Where can I simply just download the 'g++' file, without going through all these trouble?
Thanks in advance
Where can I simply just download the 'g++' file, without going through all these trouble?
Downloading the g++ file will not do you any good: the GNU C++ compiler distribution consists of several hundreds of files. The g++ is just the compiler front end, you'll also need cc1plus (the actual compiler), header files and libraries.
I started to learn Rust programming language and I use Linux. I'd like to build a cross-platform application using this language.
The question might not be related to Rust language in particular, but nonetheless, how do I do that? I'm interested in building a "Hello World" cross-platform application as well as for more complicated ones. I just need to get the idea.
So what do I do?
UPDATE:
What I want to do is the ability to run a program on 3 different platforms without changing the sources. Do I have to build a new binary file for each platform from the sources? Just like I could do in C
To run on multiple platforms you need to build an executable for each as #huon-dbauapp commented.
This is fairly straightforward with Rust. You use "--target=" with rustc to tell it what you want to build. The same flag works with Cargo.
For example, this builds for an ARM target:
cargo build --target=arm-unknown-linux-gnueabihf
See the Rust Flexible Target Specification for more about targets.
However, Rust doesn't ship with the std Crate compiled for ARM (as of June 2015). If this is the case for your target, you'll first need to compile the std Crates for the target yourself, which involves compiling the Rust compiler from source, and specifying the target for that build!
For information, most of this is copied from: https://github.com/japaric/ruststrap/blob/master/1-how-to-cross-compile.md
The following instructions are for gcc, so if you don't have this you'll need to install it. You'll also need the corresponding cross compiler tools, so for gcc:
sudo apt-get install gcc-arm-linux-gnueabihf
Compile Rust std Crate For ARM
The following example assumes you've already installed the current Rust Nightly, so we'll just get the sources and compile for ARM. If you are using a different version of the compiler, you'll need to get that to ensure your ARM libraries match the version of the compiler you're using to build your projects.
mkdir ~/toolchains
cd ~/toolchains
git clone https://github.com/rust-lang/rust.git
cd rust
git update
Build rustc for ARM
cd ~/toolchains/rust
./configure --target=arm-unknown-linux-gnueabihf,x86_64-unknown-linux-gnu
make -j4
sudo make install
Note "-j4" needs at least 8GB RAM, so if you hit a problem above try "make" instead.
Install ARM rustc libraries In native rustc build
sudo ln -s $HOME/src/rust/arm-unknown-linux-gnueabihf /usr/lib/rustlib/arm-unknown-linux-gnueabihf
Create hello.rs containing:
pub fn main() {
println!("Hello, world!");
}
Compile hello.rs, and tell rustc the name of the cross-compiler (which must be in your PATH):
rustc -C linker=arm-linux-gnueabihf-gcc-4.9 --target=arm-unknown-linux-gnueabihf hello.rs
Check that the produced binary is really an ARM binary:
$ file hello
hello: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), (..)
SUCCESS!!!:
Check: the binary should work on an ARM device
$ scp hello me#arm:~
$ ssh me#arm ./hello
Hello, world!
I've used this to build and link a Rust project with a separate C library as well. Instructions similar to the above on how to do this, dynamically or statically are in a separate post, but I've used my link quota up already!
The best way to figure this out is to download the source code for Servo and explore it on your own. Servo is absolutely a cross-platform codebase, so it will have to address all of these questions, whether they be answered in build/configuration files, or the Rust source itself.
It looks like the rust compiler might not be ready to build standalone binaries for windows yet (see the windows section here), so this probably can't be done yet.
For posix systems it should mostly Just Work unless you're trying to do GUI stuff.
Yes, you won't need to change the source, unless you are using specific libraries that are not cross-platform.
But as #dbaupp said native executables are different on each platform, *nix uses ELF, Windows PE, and OSX Mach-O. So you will need to compile it for each platform.
I don't know the state of cross-compiling in rust, but if they already implemented it, then you should be able to build all the binaries in the same platform, if not, you will have to build each binary on it's platform.
I'm thinking to write a simple configure script (similar to autoconf one) which execs cmake. But before doing that I want to check if anyone knows of such an effort already. I wasn't able to find anything on google.
It should be able to support the basic autoconf configure flags (prefix, exec-prefix, bindir mostly).
Reason to do it is of course that there's a certain user expectancy to be able to do ./configure && make
Also not really an answer but too long for a comment:
After reading up about cmake / cpack, I can at least tell you this. Cmake expects to be present on the platform. Therefore CPack cannot generate the same type of ./configure scripts as autotools. The Autotools expect some shell to be present, which is essentially the same as cmake to be present. However since cmake also targets the Win environment, it cannot rely on a shell. That being said, CPack can provide source packages, which need to be installed with cmake in the usual manner.
Also this does not solve your problem, I do not recommend to write a tool for cmake. Cmake is able to use all these type of prefixes you are interested in. If the user wants to compile your program from scratch, he has to know at least the basics (e.g. setting variables) of your build system. This is also true for autotools. If you want to spare him the pain, you can provide binary .sh, .deb or .rpm packages, which can be easily built with cmake / cpack.
I am trying to use vtune with my application compiled with mingw in Windows.
When I try to see souce code information, vtune says the is not line information in the resulting executable. I am compiling with -g option so I dont know where is the problem. So the questions are:
Is it possible to profile with a program compiled with mingw in windows? It looks like all is ready for MS-VC, but not for mingw.
If so, is it needed to change the object format (coff, xcoff, DWARF, ....)?
maybe if someone post an example it would be valuable.
Solved, compiled with
-gstabs -g3