I need to get .hex file from eclipse c++ compiler. I received only .elf file.
Eventually, I should write that binary code into controller which can adopt only binary code.
I converted the .elf file to binary file using an utility, but it’s not the way.
Oh, I forgot to say that I used atollic truestudio.
First of all Elf is “binary” file (you probably mean compiled executable). You can load that to controller using jtag/debugger. With GNU toolchain you can use objcopy to convert .elf to raw binary. Objcopy can be added as another compilation step in Eclipse/cdt, but probably your IDE provider should do this (check if there is no option to enable this already there).