Answer the question
In order to leave comments, you need to log in
Need help cross compiling a binary for different Linux systems?
The task is:
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int main()
{
std::cout << "TEST BUILDS FOR RUN LINUX" << std::endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
Just build the executable on a system with the minimum ABI version. Will run on most systems.
I think the easiest way to solve the problem is to use an interpreter. Take some python3 or Dart. Dart, by the way, is possible (compiled), but python3 is many times faster.
I think if you transfer your project to python you will not regret it, BUT it is desirable that python3 be installed on all machines if you want to transfer it in the form of source code or you can package the project through pyinstaller into an executable file.
It is possible to rewrite in Go and compile a static binary without dependencies.
https://www.arp242.net/static-go.html
The newly released Go 1.15 will have a smaller binary size than previous versions.
To compile the 32-bit version, just set a couple of variables:
GOOS=linux GOARCH=386 go build
Compile as a static binary (it is possible even under x86 to work on 32-bit and 64-bit machines).
$ echo 'int main(){ printf("Hello, World\n"); }' > xxx.c
$ gcc -static xxx.c -o xxx
xxx.c: In function ‘main’:
xxx.c:1:13: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
int main(){ printf("Hello, World\n"); }
^~~~~~
xxx.c:1:13: warning: incompatible implicit declaration of built-in function ‘printf’
xxx.c:1:13: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
$ ./xxx
Hello, World
$ ls -l xxx
-rwxrwxr-x 1 shurik shurik 844696 авг 13 22:04 xxx
$ ldd ./xxx
не является динамическим исполняемым файлом
Compile static g++ -static.
A segmentation fault, this is somewhere an error, all calls must be checked for the returned data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question