April 20, 2013

G++ and C static library with C files ( -x flag )

I faced one rather small problem which engaged me for a while. I ported C++ demo application to CodeWarrior 10.3 using g++. Linked library was compiled with gcc.
Linker was against me to build the demo. It shown undefined variable errors in static library (library plus some files which are outside of the library). I knew those undefined variables are properly declared and had to be visible to the linker. The output in a console was allright at first sight.

I explored linker settings in CW (not much to do with options there, preferably to use own linker commands). Did not do the trick. I proceeded to compiler, here's link which made it clear:

man gcc [cf.ccmr.cornell.edu/cgi-bin]

Particulary option -x none. I did not see any -x in the console output. Once I had added it into command line pattern, it linked.

"${ARMSourceryDir}/${COMMAND}" -x none ${INPUTS} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT}