0

I am building a project. The build is blocked because of stray lines in a library file.

/datablock/libcosmosis.so:72:1: error: stray ‘\377’ in program

What could cause stray lines in a library file? The library being used here was built early in the same build process. I am using gcc (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rays2pix
  • 52
  • 4
  • 1
    related: http://stackoverflow.com/questions/11025320/stray-377-in-xcode – Foon May 30 '14 at 13:22
  • 1
    A preprocessor macro is one thing. – user2672165 May 30 '14 at 13:22
  • Stray characters usually signal a wrong encoding or some formatting junk inserted here and there (or perhaps some macro messing around). Try to save the file in ASCII format and trim out the weird characters – Marco A. May 30 '14 at 13:23
  • 3
    Looks like GCC is treating that file as a source file instead of a library. Post your GCC command line. – Fred Foo May 30 '14 at 13:40
  • @larsmans gcc command, `gcc -O3 -g -fPIC -I/media/OSS/lcdm/code/cosmosis/ -std=c99 -shared -x c -o example_c_module.so example_c_module.c /media/OSS/lcdm/code/cosmosis//cosmosis/datablock/libcosmosis.so /media/OSS/lcdm/code/cosmosis//cosmosis/datablock/libcosmosis.so:1:1: error: stray â<80><98>\177â<80><99> in program` – rays2pix May 30 '14 at 13:43
  • 3
    @pd33p0k well there it is. you are not linking the .so but tryijg to compile. read a tutorial on the basic usage of GCC. – The Paramagnetic Croissant May 30 '14 at 13:49
  • I removed `/media/OSS/lcdm/code/cosmosis//cosmosis/datablock/libcosmosis.so` from the above command and it works fine. Now I will have to check why my Make is generating such strange commands with lib*.so as source files. Thanks. – rays2pix May 30 '14 at 13:50
  • \377 in the beginning of the file is a signature for [UTF-16](https://en.wikipedia.org/wiki/UTF-16) BOM ([UTF-16LE](https://en.wikipedia.org/wiki/UTF-16#Byte-order_encoding_schemes) (little-endian)) induced errors. (The full error would be the doublet "“stray \377 … stray \376”"). The canonical question may be *[How should I use g++'s -finput-charset compiler option correctly in order to compile a non-UTF-8 source file?](https://stackoverflow.com/questions/10345802/how-should-i-use-gs-finput-charset-compiler-option-correctly-in-order-to-com)*. – Peter Mortensen May 25 '23 at 10:44
  • A signature for an actual binary file ([ELF](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format)) may be 177 in the beginning of the file (octal. "stray \177" (0x7F). The next three bytes are ASCII "E, "L", and "F". – Peter Mortensen May 25 '23 at 10:57

0 Answers0