Cross Compiling C Program with mosquitto includes

I'm trying to compile a custom C program using #include <mosquitto.h>

I can compile the program successfully on my Ubuntu box using

gcc test.c -o test -lmosquitto

but when I cross compile using

mips-openwrt-linux-gcc test.c -o test -lmosquitto

I keep getting
mips-openwrt-linux-musl/bin/ld: cannot find -lmosquitto
collect2: error: ld returned 1 exit status

I have already added and compiled the firmware for my target device including
mosquitto-client-ssl
mosquitto-ssl
libmosquitto-ssl
libmosquittopp

and my program is located at ~/openwrt/package/test/
test.c
mosquitto.h

Where do I find and include the mosquitto library files so the linker can find them?

Have you included libmosquitto-ssl (or -nossl, as appropriate) as a prerequisite in your package's Makefile?

Yes. I still get the error. Is there an environment variable to specify where to find libmosquitto-ssl when using mips-openwrt-linux-gcc?

You likely need to create a package, as trying to build executables outside of the build system is "challenging, at best".

See further https://openwrt.org/docs/guide-developer/packages

I have the same error trying to build the package. I am trying to do it manually to figure out why it won't link. I need advise for creating a Makefile so it will compile successfully. The developer guide isn't helping me with this specific issue.

I think it would probably be pretty close to https://github.com/openwrt/packages/blob/master/net/mosquitto/Makefile
where, for example

DEPENDS+=+libmosquitto-ssl

adds the library dependency to the existing list of dependencies.

I still get the linker error - very frustrating. I can compile the easy helloworld examples but they are useless as soon as you add an external include. I can't figure out where/why the linker is throwing "can't find" errors even when using the explicit path.

Post your Makefile?