Is there a pre-built clang library for Windows? [closed] - windows

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I am developing a tool using the clang library on Linux and I would like to port this tool to Windows.
On Linux, I can install Clang from the LLVM repositories using apt-get clang-6.0-dev and simply link my tool with -lclang. I do not need to compile LLVM and Clang myself.
Is there a way to do something similar on Windows, or do I need to compile the Clang library myself?
All of the Clang-related posts I could find are about using clang as a tool, not as a library.
I have installed the pre-build executables for Clang and LLVM from the LLVM website, and these work nicely in combination with mingw. However, the download for Windows does not seem to include the Clang library as a separate file (DLL), and linking with -lclang results in a linker error.
If there is no pre-built library for Windows, what is the best way to proceed, preferably using mingw and not MSVC?

There are pre-built LLVM/clang binaries on Zig's github page:
https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows
You can find libclang.dll in the bin folder.
The currently available versions are:
llvm+clang-6.0.0-win64-msvc-release.tar.xz
llvm+clang-7.0.0-win64-msvc-release.tar.xz
llvm+clang-8.0.0-win64-msvc-release.tar.xz
llvm+clang-9.0.0-win64-msvc-release.tar.xz
llvm+clang+lld-10.0.0-x86_64-windows-msvc-release-mt.tar.xz
There are also detailed build instructions, here.

For anyone coming to this question that's just looking to install libclang on their system, the choco llvm package appears to install libclang correctly. I can't speak to whether this is adequate for actually linking against this library for C/C++, but it worked for my case.
Just run this in an elevated command prompt or powershell:
choco install llvm
You may need to run refreshenv or open a new console for tools to pick this up.
In my case, and to help with future googlers (since I couldn't find a simple answer elsewhere) my issue was specifically while trying to compile a Rust project that made use of the onig_sys crate:
Compiling onig_sys v69.2.0
error: failed to run custom build command for `onig_sys v69.2.0`
Caused by:
process didn't exit successfully: `[redacted]\target\debug\build\onig_sys-b53394f57ee5e2c5\build-script-build` (exit code: 101)
--- stdout
cargo:warning=couldn't execute `llvm-config --prefix` (error: The system cannot find the file specified. (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable
--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'clang.dll\', \'libclang.dll\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', src\libcore\result.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
After installing llvm, the cargo build finished successfully

Related

Is there any way to run an amd64/linux VM on Apple Silicon M? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm writing a program about transparent proxy with Go, but syscall.SetsockoptInt(int(s), syscall.SOL_IP, syscall.IP_TRANSPARENT, 1)is only supported on amd64/linux (Other versions don't have constant syscall.SOL_IP and syscall.IP_TRANSPARENT).
So even if I run a parallel VM (arm64/linux) on M1, I still could not build my program successfully. Is there any way to solve it?
I'm not sure what's the essense of the question. IP_TRANSPARENT is specific to Linux (an OS kernel), so any code which makes use of it must run on Linux. Debugging (a running process) also must happen on Linux—for, I hope, reasons now obvious.
But that does not affect building: when building on Linux, that should work if your version of Go has IP_TRANSPARENT defined in its syscall package.
This means:
Running the program built for linux/amd64 making use of syscall.IP_TRANSPARENT on the VM with a Linux guest should work.
Building that program from the source code on the VM with a Linux guest should work.
But "plain" building on a non-native platform (which is darwin/arm64 in our case, if I understand correctly) will not work, and this might be the source of your confusion.
Basically, when you're building the source code on darwin/arm64, the compiler locates, reads and interprets all the sources expecting to produce an executable image file suitable for the platform it's working on; the syscall package, being highly OS-dependent, can be though of as being different for different GOOS/GOARCH combos.
Its "version" for darwin/arm64 simply cannot contain the symbol IP_TRANSPARENT because the darwin kernel does not "know" about it.
So, if your issue is merely building for linux/amd64 while working on darwin/arm64, the answer is cross-compilation.
With Go, it's done by making the toolchain see explicit settings for the GOOS and/or GOARCH environment variables—different from the assumed defaults.
In your case you could just do
$ GOOS=linux GOARCH=amd64 go build
and it will produce an executable image file ready for linux/amd64, and when processing the source code, the compiler will use the definitions for the target platform, not the platform it's running on.
You can then copy (or make availabe by other means) the produced executable image file to the guest's filesystem and run it there—it should work just fine.
You can make such changes "permanent" for the current Termial session by doing
$ export GOOS=linux
$ export GOARCH=amd64
TL;DR
To build for a non-native platform, use cross-compiling; you do not need any sort of VM.
Or you can build "natively" but then you need to install go into the guest running on a VM, and make the project's source code available there.
To run an executable for a non-native system you must use a VM (or some sort of emulator).

How to install hyperion 2.2 on kali linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I want to install hyperion 2.2 on kali linux. This version of hyperion is different than previous: there is no .cpp files (now hyperion is C). So command
'i686-w64-mingw32-c++ Hyperion-1.2/Src/Crypter/*.cpp -o hyperion.exe'
doesn't work.
I've also tried:
mingw32-make
bash: mingw32-make: command not found
Please, help.
The following command worked for me to compile with no warnings or errors. Although I have not fully tested the resulting executable yet:
i686-w64-mingw32-gcc -ISrc/Payloads/Aes/c Src/Crypter/*.c Src/Payloads/Aes/c/*.c -o hyperion.exe
Running the file command on the resulting hyperion.exe gives:
hyperion.exe: PE32 executable (console) Intel 80386, for MS Windows
i686-w64-mingw32-gcc -I Hyperion-2.3.1/Src/Payloads/Aes/c Hyperion-2.3.1/Src/Crypter/.c Hyperion-2.3.1/Src/Payloads/Aes/c/.c -o hyperion.exe
this command works for kali 2020.3 mingw-w64 V.8 and Hyperion-2.3.1
make sure to separate -I from Hyperion-2.3.1 and make sure to include full file path i.e. Hyperion-2.3.1/Src/Payloads/Aes/c/
I am the author of Hyperion. Hyperion is a Windows application and I am not very familiar with cross compiling issues on Kali Linux. Nevertheless, I can give you two hints to point you into the right direction:
If you want to use the makefile: mingw32-make: command not found means, mingw32-make is not installed. You have to use apt to install it. Something like sudo apt-get install gcc-mingw-w64 or apt install mingw-w64 should solve the issue. You can also use apt search mingw to find the corresponding package.
If you want to build it by calling the compiler yourself: The AES dll was replaced by TinyAES. It can be found here: Src/Payloads/Aes/c/aes.c. So you have to add it to your source path as well.
Kind regards,
Christian
hyperion 2.2 and 2.3 has a makefile, I change compiler gcc to i686-w64-ming32-gcc, and modify CFLAGS, it can compile.

Instruct stack to use the already installed MinGW

I have msys2 installed separately from GHC. MinGW toolchain is installed inside of the msys environment. Now I'm running into issues with some native libraries that work when I use them outside of Haskell, but don't work when ran from Haskell code.
The problem is that commands like stack exec and stack repl prepend GHC's MinGW folders to the PATH and then you get things like one dynamic library being found in my msys installation, while it's dependency is first found in GHC's MinGW installation and the whole thing doesn't work.
Stack provides a skip-msys option to avoid using the msys environment that it installs, but as far as I can tell there's no way to skip the GHC-provided MinGW toolchain.
What can I do about this?

How to cross compile from Mac to Linux?

I wrote a little game using Rust, and I used cargo build --release to compile a release version on Mac.
I tried to share this with my friend who is using Ubuntu, but when he tried to run the binary, he got the following error:
cannot execute binary file: Exec format error
I searched for this but found no answers. Doesn't Rust claim to have "no runtime"? Shouldn't it be able to run anywhere in binary form?
Rust not having a runtime means that it doesn't have a lot of code running as part of the language (for example a garbage collector or bytecode interpreter). It does still need to use operating system primitives (i.e. syscalls), and these are different on MacOS and Linux.
What you want is a cross compiler. If you're using rustup, then installing a cross compiler should be simple:
# Install the toolchain to build Linux x86_64 binaries
rustup target add x86_64-unknown-linux-gnu
Then building is:
cargo build --release --target=x86_64-unknown-linux-gnu
Caveat: I don't have an OS X machine to test this on; please comment or edit to fix this if it works!
Well, it is because Rust has no runtime (unlike e.g. Java's JVM) that you can't just compile code on one OS and expect it to run on a different one; what you are looking for is cross-compilation. I haven't done it in Rust, but from what I can gather you can find relevant information on different cross-compilation Rust strategies on this GitHub repo.

Rust Installation on Windows for developing GUI apps

TL:DR;
Can I write GUI programs on Win 10 (64) using Rust without installing the full MinGW toolchain (nor the MS equivalent)?
Supplementary questions:
- If not, should I just go ahead and install MinGW?
- Does anything GNUish in Windows 10 Anniversary Update change any of this?
Longer version
I saw that Rust is the most loved programming language hereabouts so 15 minutes ago...
I read
No additional software installation is necessary for basic use of the GNU build.
Rust's support for the GNU ABI is more mature, and is recommended for typical uses.
So I downloaded Windows (GNU ABI †) (.msi) 64-bit to my PC running Windows 10.
TUI
I read some basic intro and used rustc to compile a Hello World! and ran it OK. I then read about cargo and reorganised buit and ran the same code using that.
GUI
I then searched for Rust GUI and found Kiss_UI
a simple UI tookit for Rust
So I did a cargo new Hello_GUI --bin and added
[dependencies.kiss-ui]
git = "https://github.com/cybergeek94/kiss-ui"
to Cargo.toml
I cut and pasted a simple example from that website into main.rs
I then ran cargo run --verbose. It did
Updating git repository `https://github.com/cybergeek94/kiss-ui`
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading iup-sys v0.0.3
Downloading libc v0.2.14
Downloading libc v0.1.12
Compiling libc v0.1.12
...
warning: crate `Hello_GUI` should have a snake case name such as `hello_gui`, #[warn(non_snake_case)] on by default
error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" ...
note: ld: cannot find -liup
error: aborting due to previous error
So I learned two things
I need to use snake case.
GUI programming is not "basic use".
I have no complaints about either of these points but could use a clue or two about the second:
Assuming I want to write a GUI equivalent of Hello World in a simple way, what are my main options now?
According to its documentation, kiss-UI depends on the IUP library.
The error from gcc (can't find -liup) suggests that you don't have IUP installed. You may be able to install it and have things work; it depends on whether the IUP bindings used by kiss-UI can cope with windows.
Some other GUI libraries can be found at awesome-rust. There are bindings to libraries like Qt and Gtk. If you know the windows API, you could also check out the winapi crate.
If you want to avoid messing with linking and stuff, you could try using a pure rust library like conrod, which should 'just work' on windows.
To answer your more broad questions:
See the footnote on the downloads page. The MSVC version of rust depends on MSVC being installed. The GNU/MinGW build is standalone.

Resources