Build app to run on x86-64 OpenWrt

Hello Guys,

I run x86-64 openwrt as a docker container on my x86-64 ubuntu host.
I build a simple app on my x86-64 ubutun and want to run this app on my openwrt container, but it failed.

here is my app code on ubuntu:

#include

using namespace std;

int main(int arc, char* argv[])

{

cout << "success!" << endl;

return 0;

}

using the below command to build the app.
g++ test.cc -o testapp

then run this app inside the openwrt docker container, it complained:
./testapp
/bin/sh: ./testapp: not found

Do you know why and how I can debug the issue? I guess there may some libraries missed inside the openwrt docker container.
Thank you very much!

Openwrt by default uses musl, not glibc, so there is no binary compatibility with applications compiled on a typical Linux distro. You need to cross compile for Openwrt.

If you build your own version of openwrt with glibc, then there is theoretical binary compatibility, depending on what versions of the libraries you have installed on your host system and you link against. No guarantee it will work, but most do on mine if the right libraries are installed on the target or the app is statically linked.

You really need to cross compile applications for your Openwrt. Look at the documentation on Openwrt's SDK and the buildroot system. There is a steep learning curve though

Thank you very much! dl12345.
My openwrt x86-64 docker image is pulled from: https://hub.docker.com/r/openwrtorg/rootfs
docker run --rm -it openwrtorg/rootfs:x86-64

I want to build my own apps on ubuntu and then to run it inside this openwrt container.
Do you know which cross compile I should use? thank you very much!

https://openwrt.org/docs/guide-developer/build-system/start
https://openwrt.org/docs/guide-developer/build-system/use-buildsystem
https://openwrt.org/docs/guide-developer/packages
https://openwrt.org/docs/guide-developer/single.package

Thank you very much!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.