Cant pick up zlib on a cross compile?


I'm quite new to this so have probably made a numpty mistake.

I have installed and built a lede image on an x86 machine, set its image to mips and its built fine. I have then created a package, that builds fine (and deploys to target and runs having opkg install mypackage). So the basic build/cross compile looks good.

However as soon as I add zlib calls to the package code its fails to build, giving link errors of 'undefined reference to `deflate' etc. I have included -zlib to the DEPENDS section of the package.

I have checked zlib in the build image and it produces a ipk file. So that is built.

What do I need to do to include picking up the zlib library from my package build, or the steps to prove what is going wrong?

Many thanks for you time/help.


Make sure your package has DEPENDS:=+zlib and that your compile / linker args contain -lz.

If you use an inner Makefile, add -lz to its LDFLAGS, if you build straight from the outer Build/Compile try TARGET_LDFLAGS += -lz. It really depends on your current Makefile structure.

1 Like

The combination of those worked, thanks very much :slight_smile:

I was scratching my head over adding -lzlib :hot_face: This helped a lot, now code compiles.