C executable not recognized in router

I have created a program consisting of a zeromq client (in C), like so:


I installed libzmq-nc on my OpenWrt router (18.0.2) and libzmq on my computer.
However, when I compile the C file on my computer (same architecture as the router: x86_64) and transfer the executable to the router, even after giving permissions for execution (chmod +x), the terminal tells me:

root@OpenWrt:~# ./zmq_client
-ash: ./zmq_client: not found

So, I thought that maybe I should use the SDK to compile this program of mine. Inside the SDK folder, I created a folder under "packages" named "zeromq_client", with the following Makefile:


and a "src" folder inside that "zeromq_client" folder, that contained the source (.C file - my program) and the Makefile presented next:

# build helloworld executable when user executes "make"
zmq_client: zmq_client.o
$(CC) $(LDFLAGS) zmq_client.o -lzmq -o zmq_client

zmq_client.o: zmq_client.c
$(CC) $(CFLAGS) -c zmq_client.c

# remove object files and executable when user executes "make clean"
rm *.o zmq_client

I did all this following some tutorials on the Internet. The only thing that is different in my solution is the name of the package in the Makefiles, which I changed to the name of my own and I added a link to the -lbzmq library in the third line of the above Makefile.

When I run "make -j1 V=s", it results in errors:


Does anyone have a clue on what the problem could be? It's not that I need to cross-compile, as the architectures are the same. I don't know if it might be a problem with the Makefile structure, or maybe the way I'm linking the libzmq...

This is a program I can compile on my computer (I've tested the Makefile inside the src and the program executes without errors). Also, none of the the lines of the error above mention my program, I'm confused.

Note: 3 of the outputs were too long and I couldn't get them to format here quickly, so I used pastebin.

BTW, reading, is seems like simple errors in the C code.

1 Like

What is the output of file zmq_client and ldd zmq_client? Run on the router.

“not found” where the executable exists and is marked as executable often indicates that the libraries are incompatible. Generally code needs to be built using the OpenWrt build chain, even for x86_64.


@lleachii None were successful. First, I compiled on my computer and moved the executable to the router, and the "~ash" error appeared. Then, I tried compiling with the SDK, and at the "make" step, the errors of the 3rd pastebin appeared.

Isn't that library for C++? My code is in C.

I'm pretty sure it is not an error on the code, because I can compile that .c program an run it on my computer successfully.


root@OpenWrt:~# file zmq_client
zmq_client: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=4ae97b696986262de690267a715f7d42b210f0ba, with debug_info, not stripped


root@OpenWrt:~# ldd zmq_client
/lib64/ld-linux-x86-64.so.2 (0x7f0efb732000)
libzmq.so.5 => /usr/lib/libzmq.so.5 (0x7f0efb4df000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0efb732000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f0efb3a5000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f0efb391000)

@jeff but I'm using the SDK, isn't that what you mean by "using the OpenWrt build chain"? I thought that, when I was doing (in the SDK)...

./scripts/feeds update -a
./scripts/feeds install <my_package>
./make menuconfig
./make V=99

... these steps, I was already creating an executable compatible with the OpenWrt libraries and architecture (taking into account the SDK is of the same version as the OpenWrt in my router) :confused:

1 Like

It might also be possible that you're using the system build tools and not the OpenWrt tool chain.
Check your path.

Just a thought.

You have to also build the library on OpenWrt. The prebuilt one you're loading likely doesn't match the C libraries.

@mhel I executed the following:

  • PATH=$PATH:(your toolchain/bin directory here)
  • export PATH

as described in the SDK tutorial. I'm sure I'm using the right path, I just checked it.

@mk24 I executed:

root@OpenWrt:~# ldd zmq_client
/lib64/ld-linux-x86-64.so.2 (0x7fe4939de000)
libzmq.so.5 => /usr/lib/libzmq.so.5 (0x7fe49378b000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fe4939de000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fe493651000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7fe49363d000)

on my router. As you can see, there's a mismatch on libc.so.6, as it is linking to a different lib (?).
I just searched the router's filesystem and there is no "ld-linux-x86-64.so.2" file on the /lib64 folder. Maybe it does not exist in the filesystem but only in memory, according to the first answer in https://stackoverflow.com/questions/34428037/how-to-interpret-the-output-of-the-ldd-program

Should I be concerned about this ldd output? How should I compile this lib in the SDK? How do I compile my original program so that it is linked with that different lib?

EDIT: I'm going crazy with this, because, using this tutorial: https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/c-c++-programming/using-openwrt-sdk-to-build-c-c++-programs ...
...I successfully compiled a simple helloworld in .c on my computer (using the SDK) and executed it, also successfully, in my router.

EDIT2: I didn't use the mediatek SDK, but the latest version of OpenWrt SDK. I just used the .C source files of the tutorial and followed their steps. I'm sorry if I was not clear before.

The problem is that your pre-compiled libzmq is compiled against standard C libraries that aren't present on the OpenWrt install. The easiest solution is to also build libzmq from source code.


The MediaTek SDK, while based on an (old) version of OpenWrt, is very different than the current OpenWrt. They aren't "binary compatible".

It must be related to a different, or older version of OpenWrt.
The error you were getting seems too be exactly like this:
which is from 2018.

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