Hi


I am using eclipse.I got error.I am using g++ complier.

*.o : file not recognized: File format not recognized
collect2: ld returned 1 exit status

Please any one help me..

As far as I know it happens after "compilation" of .h files.
Insufficient info...

A '.o' file is normally an object file, are you trying to link an object file to an executable file ?

Maybe you should check out this also ...

Insufficient info...

Agreed

As far as I know it happens after "compilation" of .h files.
Insufficient info...

yes. It happens after compilation of .h files.
you mentioned insufficient information.
can you tell what information you want about this problem.

A '.o' file is normally an object file, are you trying to link an object file to an executable file ?

Maybe you should check out this also ...


Agreed

yes, .o file is an object file.
I am trying to link an object files to the library files.
This same program i complied successfully in Netbeans using g++ complier
Now I am using eclipse.

I am trying to link an object files to the library files.

To create a static library from an object file you just need to invoke the following command: ar -rv lib[U]yourlibfilename[/U].a [U]yourobjectfile[/U].o

To create a static library from an object file you just need to invoke the following command: ar -rv lib[U]yourlibfilename[/U].a [U]yourobjectfile[/U].o

Hi

I won't create static library file from object file.
already I created static and dynamic library file.Now I am trying link object file to library file.
Any special properties setting is need in ecplise editor?

yes. It happens after compilation of .h files.
you mentioned insufficient information.
can you tell what information you want about this problem.

Well, you have compiled .h files as independent modules... But WHY?..

why not something like cc -o a.out obfile.o -lmylib.a

why not something like cc -o a.out obfile.o -lmylib.a

That should do the trick, if I'm not wrong the following also works: g++ -o a.out obfile.o -lmylib.a

That should do the trick, if I'm not wrong the following also works: g++ -o a.out obfile.o -lmylib.a

Hi

I can't understand.Please explain it.

Hi
I can't understand.Please explain it.

g++ -o a.out obfile.o -lmylib.a > Well, let's start with the beginning: g++ is the C++ compiler ...
> The -o specifies that a.out is the output file (this is actually the executable file)
> [U]obfile[/U].o is the object file (from your main program) which you did already compile ...
> -l[U]mylib[/U].a is your static library you're linking to your program ...

Maybe you also might want to read this tutorial about g++ ...

Hope this helps ! :)

Edit:: You have to replace obfile and mylib with the filenames of the files you're compiling ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.