Trying to compile a load of .c files
(1) The files compile ok, using cc
cc -Wall -Wextra -Wunreachable-code -ggdb -O0 *.c
(2) Then, I need to make a static library from the final output, to use in a c++ program. So I do:
ar cru liborientdb-c.a *.o
(3) Works ok. However when I come to compile the c++ program testme.cpp that includes the library in line #1
(line 1 of testme.cpp)
#include "liborientdb-c.a"
Compile step:
cc testme.cpp
i get this error:
liborientdb-c.a:117:22: error: stray '\3' in program
liborientdb-c.a:117:263: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\17' in program
liborientdb-c.a:117:265: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:283: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\22' in program
liborientdb-c.a:117:287: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\1' in program
liborientdb-c.a:117:289: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\362' in program
....
So, following the advice on some others posts here, i believe the errors could be due to messed up encoding.
So i used 'od -c' and to try and trace where the "octal flow" is getting messed up. The output for one of my .o files after with 'od -c' looks pretty bad, so i think that could be the reason.
EG.
0000000 177 E L F 002 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 001 \0 > \0 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000040 \0 \0 \0 \0 \0 \0 \0 \0 ` ( \0 \0 \0 \0 \0 \0
0000060 \0 \0 \0 \0 @ \0 \0 \0 \0 \0 @ \0 026 \0 023 \0
0000100 U H 211 ? H 203 ? 020 H 211 } ? H 211 u ?
0000120 H 213 E ? H 213 \0 H 213 @ \b H 205 ? t 023
0000140 H 213 E ? H 213 \0 H 213 @ \b H 211 ? ? \0
How can i fix this though? I actually followed the advice here and ran on my lib source files
recode UTF8..ISO-8859-15 *.c
The response is the files remain unchanged (the last modified date is still old). So then I open my .c files and see they are in UTF-8, which is apparently a subset of ASCII. So it would seem no issue then.
But the .o files still look weird.
How to proceed ???
#include "liborientdb-c.a"
.a files are not C source files. Or even text files for that matter.
Usually, the .a files are added on the final link line of the compilation.
cc -o something file.o file2.o liborientdb-c.a etc etc
You are including a binary file in your .cpp source
(line 1 of testme.cpp)
#include "liborientdb-c.a"
Look for a header file named "liborientdb-c.h", and include that (guessing, you probably want to include all of the appropriate *.h header files).
And your makefile should link against the above .a file.
来源:https://stackoverflow.com/questions/19149060/c-compiling-error-stray-4-in-program-octal-flow