-   Solaris / OpenSolaris (
-   -   Compiler error : /usr/lib/ file not recognized: File format not recognized (

kreena 11-30-2009 08:21 AM

Compiler error : /usr/lib/ file not recognized: File format not recognized
I am compiling a .c file with gcc & getting this

> gcc -o test.o test.c
/usr/lib/ file not recognized: File format not recognized

I tried it on bach as well as with csh. Getting the same error.

> ls -l /usr/lib/
lrwxrwxrwx 1 root root 19 Apr 7 2009 /usr/lib/ -> ../../lib/

PS: I am on Solaris : Solaris 10 10/08 s10s_u6wos_07b SPARC

jlliagre 11-30-2009 10:49 AM


Originally Posted by kreena (Post 3774311)

> gcc -o test.o test.c

That should be either:

gcc -c -o test.o test.c
(with "-o test.o" redundant) or

gcc -o test test.c
However, this doesn't explain the main issue:

/usr/lib/ file not recognized: File format not recognized
What says:

file /usr/lib/

kreena 12-03-2009 01:44 AM

Hi jlliagre

With gcc -c its working fine. Thanks a lot for your reply.

However, now I am not able to link thread libraries with it.

$ gcc -c -o test -c test.c -lthread
gcc: -lthread: linker input file unused since linking not done.

Can you suggest how can I proceed here.

Thanks in advance.

jlliagre 12-03-2009 11:49 AM

Remove the "-c" if you want to build an executable and please answer to my previous question (file /usr/lib/

kreena 12-04-2009 06:51 AM


$ file /usr/lib/
/usr/lib/ ELF 32-bit MSB dynamic lib SPARC32PLUS Version 1, V8+ Required, dynamically linked, not stripped, no debugging information available

After removing -c option I am getting previous error : File format not recognized

jlliagre 12-09-2009 10:03 PM

Are you using the gcc bundled with Solaris or some other version you installed ?

kreena 12-14-2009 12:44 AM


I am using

$ gcc -v
Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/specs
gcc version 2.7.2

jlliagre 12-14-2009 03:51 AM

That's not the Solaris bundled one. You might want to try again with:

$ PATH=/usr/sfw/bin:$PATH
$ gcc -v
$ gcc -o test test.c

All times are GMT -5. The time now is 10:59 AM.