top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

embedding compile options in C/C++ program

+1 vote
316 views

Is there a conditional define that expands to a string of the full gcc command-line used to compile the given .c/.cc file? I'd like to embed in the executable the exact compilation options used to build it.

posted Jun 9, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer
answer Jun 9, 2013 by anonymous
Similar Questions
0 votes

I'm studying about C compiler for increasing software quality. So I want to get all of compile error message list of gcc about C language. I was trying to find it. But I can't find it anywhere. How can I find it?

Please help?

+2 votes

I need to use microhttpd.a and pthread.a to build a cross-compiled program to be deployed on an arm-linux-gnueabihf device.

Where can I find instructions on how to do this? Or, is this simply a matter of downloading the source code and compiling (on a 64 bit UbuntuPC) to a library with my existing gcc-arm-linux-gnueabihf-4.8 cross-compiler?

While I may be able to find microhttpd.a and pthread.a binaries for an arm-linux-gnueabihf device, they will likely have been built with a different version of gcc-arm-linux-gnueabihf, which, I fear, could open up a can of worms.

+2 votes

I want to build a 'static toolchain', with option --disable-shared, for no shared library include/depend in the toolchain-self

cause I don't want the target binary runs depend on the toolchain, such as libc.so, ld-xxx.so.

But when the target binary need the function dlopen, it give a build error that libc.a need to recompile with -fPIC

So, how to compile glibc with -fPIC? or maybe I should ask is it possible to gen a shared library with
static toolchain?

0 votes

I'm running Ubuntu 13.04 on an intel machine and I want to cross compile helloworld.c so that the resulting binary will execute on Ubuntu on a powerpc machine.

So something simple like:

gcc helloworld.c --target powerpc-linux -o helloworldppc

But the answer seems to always come back how to cross compile gcc itself...

...