Imme22009
Imme22009

Reputation: 4129

C Compiling: error: stray '\4' in program ; octal flow?

I am 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) It 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.

For example,

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 this on my library 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 not seem to be a issue then.

But the .o files still look weird.

How can I proceed?

Upvotes: 0

Views: 2495

Answers (2)

Charlie Burns
Charlie Burns

Reputation: 7044

Look at:

#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

Upvotes: 9

ChuckCottrill
ChuckCottrill

Reputation: 4444

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.

Upvotes: 4

Related Questions