.h and .a files

We have a code where we have a lot of constants declaration within a .h file - this .h files gets included to multiples .cpp files which is used to create multiples .a library - now these .a files are linked to one executable. For the output and profiler I understand that this way it results the constants (declared in .h file) to be loaded into memory over and over again when different library method are referenced in code. This leads to a lot of un-necessary execution time.

Is there any way (apart from writing the constants in a .so file) we can make use? Is my assumption correct related why the constants are getting loaded multiple times due to reference of different library?

Building in constants usually means a performance improvement. They can often be built right into the machine code using instructions that take a literal value( i.e. a single instruction literally meaning 'x+=2') The program doesn't need to waste memory on the constant, bother retrieving it for anywhere, or waste a register storing it when you need to do anything with it. So you get more work with fewer and simpler instructions.

If your constants are being stored in memory at all, let alone over and over, you might be doing it wrong. Since you didn't post your .h file though, I'd only be guessing at how.