Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling previously preprocessed file changes output

I have a source file which I preprocess using the options -E and -P (using GCC 4.1.2 for a vxWorks-based embedded platform). All other options are the same as when I compile the file. These options are:

-Wall  
-march=pentium 
-nostdinc 
-O0 
-fno-builtin 
-fno-defer-pop
-g  
-c
-o

as well as all include-paths. Now when I compile this preprocessed file, the resulting object-file is much smaller (about 30%) than when I compile the original directly. And when I then link the program, the linker complains about missing symbols (all in user-code), which again does not happen when using the original source-file. Why is there a difference? Is there any way to make this work?

like image 310
Björn Pollex Avatar asked Nov 04 '22 06:11

Björn Pollex


1 Answers

You're sure you're not missing any -D defines from your command line? Your result would be consistent with parts not being compiled due to conditionals.

Another possibility (since you don't name the compiler specifically) is that you're using a generic gcc -E rather than the arch-specific cross compiler for your vxWorks environment. The cross-gcc will predefine some variables that you'll need for gcc -E.

like image 67
Ben Jackson Avatar answered Nov 09 '22 05:11

Ben Jackson