1

I would like to use only a windows system to get the compiled linux files. Is it possible? (Why can it be useful for me? For CICD purposes.)

I am interested in the opposite way too. So, making windows .exe-s in a linux system with clang.

Darffire
  • 21
  • 4
  • 1
    There's more to a C++ program than just its source code. In order to compile and build an executable Linux program one needs to have Linux-specific header files and all Linux libraries the C++ program gets linked with. Without some kind of an installed Linux system, where do you think you can get all of that from? – Sam Varshavchik Jan 14 '22 at 14:33
  • I can understand, but why should I run a whole operation system just to give some extra data to the compiler. I would give an offline WSL file witch contain every linux thing, but do not use my processor. This is just data. – Darffire Jan 14 '22 at 14:39
  • 1
    You could try to for example download Gentoo stage archives, it contains the overall linux system structure with all the libs, and point clang to it. There's no guarantee it will work, it would be easier to just set up docker or wsl machine, it doesn't take much resources if it's idle when not compiling. – Kaldrr Jan 14 '22 at 14:49
  • There is this question but Its not really solved: [https://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux](https://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux) – drescherjm Jan 14 '22 at 14:56
  • mingw which you can run on linux allows you to do the opposite meaning build windows binaries on linux. – drescherjm Jan 14 '22 at 14:57
  • Well, that's what the "whole operation system" consist of: "header files and all Linux libraries". Once you install them, you will discover that you ended up installing a complete Linux system. – Sam Varshavchik Jan 14 '22 at 15:16
  • You could install a minimal linux OS in WSL or some other container then add the development headers and compilers. That should not take a huge amount of space. – drescherjm Jan 14 '22 at 15:27
  • Thanks for the advices. I will try to solve the problem. I already have a solution with WSL. I just would like to know, is there any other option where I should not start any kind of virtual machine or program. So, I just want a formulat (clang++) with the necessary data (main.cpp and necessary linux files), to make the ELF binary in a windows system. Theoretically it should be possible. – Darffire Jan 14 '22 at 15:48
  • The coding "boss" of the team solved the problem but did not show anybody to how. So, there is a solution for this but still a mystery and will be because I left the company. (The solution was necessary for CI/CD purposes and safty critical system development regulations.) – Darffire Apr 29 '22 at 07:03
  • Perhaps the real question is how to configure your CI/CD solution to use WSL or Linux? – Panagiotis Kanavos Dec 28 '22 at 14:30

1 Answers1

0
clang++ --target=i686-pc-linux -fuse-ld=lld -nostlib  -o zpipe aa.cpp --verbose
Burak
  • 2,251
  • 1
  • 16
  • 33
BinSys
  • 981
  • 7
  • 3
  • 1
    Code-only answers can be improved. Can you edit this answer to provide context on how it addresses the question? – Alexander L. Hayes Dec 28 '22 at 15:38
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/33512392) – Parisa.H.R Dec 28 '22 at 16:51
  • 1
    @Parisa.H.R - code-only answers are not amazing, but you shouldn't recommend deleting them. See, for example, "[You're doing it wrong: A plea for sanity in the Low Quality Posts queue](http://meta.stackoverflow.com/q/287563/1364007)" – Wai Ha Lee Dec 28 '22 at 17:13