You may need to modify the Makefile of your software package or modify your .bb file to pass whatever settings required to the Makefile. I assume your .bb recipe provides instructions to compile a software package.
When you use Yocto .bb to build a software package, the "CC" variable value is automatically defined by Yocto and --sysroot is set to the BSP's rootfs.
I often had to change Makefiles to not let "CC" orverriden.
e.g.
Yocto defines CC = "arm-poky-linux-gnueabi-gcc <and some CPU specific options>"
Makefile (example)
CC = -g -O2 <--- this assignment statement overrides the default defined by Yocto and may also switch the compiler to a different or a non-existent compiler.
A potential fix is "CC ?= -g -O2" <--- this statement will initialize CC only when CC has not been assigned.
Anyway, this is just a probably cause. You may want want to read documents on Yocto and openembedded.
Sometimes I like to bypass the Yocto bitbake and .bb recipe file.
I would just use the toolchain directly.
Here are the general steps for creating the toolchain.
1. After you have created a BSP image for your target with a bitbake command, execute the following command to prepare for installation of a SDK
"bitbake <bsp-image-name> -c populate_sdk"
e.g. "bitbake core-image-base -c populate_sdk"
2. After the command is finished, deploy the sdk.
a. Go to ../<BSP>/<build dir>/tmp/deploy/sdk
b. sudo ./<whatever the name of the .sh script file>
c. Use the default installation location.
3. Start a new shell session and go to /opt/<whatever the name>/
find the "environmentXYZ.sh"
4. Execute the .sh with the "source" command"
5. At this point the shell session should have all necessary environment variables for the cross-compiler toolchain.
6. In the same shell session run the target Makefile. Note: You may still need modify the Makefile to eliminate any potential override.
Note: you can look at the environmentXYZ.sh file to see what environment variables have been added to the shell session.
You'll see how "CC" is defined and etc...
good luck!