VC2019 Link errors only in release mode

Hi,
I have developed a Raspberry PI OpenCV application using opencv 4.5.3 using Visual studio’s cross platform capabilities. I am developing on my PC with an SSH connection to the Pi.

The application links in debug mode and runs properly. As soon as I try a release build I get a linker error for an undefined symbol. I’ve verified that my debug and release linker input files are identical and have tried removing and reinstalling opencv from the Pi, but that didn’t change the problem. I built opencv from source without any errors.

Here’s the release mode linker error:

Severity Description File Line
Error //usr/local/lib/libopencv_core.so.4.5: error adding symbols: DSO missing from command line D:\usr\bin\ld 1
Error //usr/lib/arm-linux-gnueabihf/libc_nonshared.a(elf-init.oS) C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets 552
Error /home/pi/projects/oc/obj/ARM/Release/oc.o: undefined reference to symbol ‘_ZN2cv3MataSERKNS_7Scalar_IdEE’ D:\usr\lib\arm-linux-gnueabihf\crt1.o (__libc_csu_init\usr\bin\ld 1
Error Archive member included to satisfy reference by file (symbol) C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets 552
Error ld returned 1 exit status) D:\Optel\UofR\Pi_Software\ocularus\collect2 1

Any idea why this happens?

Thanks,
Scott