So we have for example ffmpeg that can b开发者_运维百科e compiled into > than 4 libraries. Is it possible using GCC to compile\collect not into .a or .so libraries but into some wary large one C files?
Funny question, why would you want to do this? Anyway, you can try and see whether gcc -E
does what you want - it only invokes the preprocessor. So you might have to adapt the source code to include other source code files.
MiLu@Dago: ~ > cat x.c
int x_num() {
return 7;
}
MiLu@Dago: ~ > cat moin.c
#include <stdio.h>
#include "x.c"
int main() {
printf("moin: %d\n", x_num());
return 0;
}
MiLu@Dago: ~ > gcc -E moin.c | wc -l
1150
I think I'd rather try the cat
utility:
find -type f -name \*.c | xargs cat > all_my.c
Still, what are you trying to achieve?
You may use cpp with -M family of arguments to generate a make file describing the code dependencies, then add a rule for .c and .h files to append content to the same file.
If the application is not using #ifdef guards within .h files it may cause warnings about macros defined twice.
精彩评论