file not recognized: File format not recognized


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..
what exactly you are doing, can you explain a bit?
Hi

thanks for ur reply.

I got link error.Ecplise editor created the object file for that .cpp file.After compiling, object files and library files are linking.
at that time i got this error.

For Example, SGConfiguration.cpp ---------------> SGConfiguration.o
hello.cpp ------------------------------> hello.o


this is the full error


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


This same program i complied successfully in Netbeans.


What can i do for this error?





Last edited on
you have only one file??

try compiling directly.

if you have only one file then you can do simple g++ "file_name".
like g++ SGConfiguration.cpp. thats all.

if you have multiple files then you can create makefile for them. i can help you in creating your makefile.

Hi

no....

I have multiple file.Totally 350 files (approximately).

how can i create make file.
help me....
:o ....ohoooo..

actually i dont have any idea of netbeans or eclipse... how they work or compile the source..

i just saw you are working on windows.. otherwise you could have used autoconf and automake to create makefiles on linux/unix for large number of files.. thats a very easy process.. but i dont know if automake work on windows..leave this..

which platform you compile your code with netbeans??

on windows it is easy to use visual studio but i dont know if you have visual studio?

Hi

I used Linux platform for compile the code with Netbeans.
Could u explain autoconf and automake to create makefile on Linux/UNIX.
ok.. lets make a simplest project.

mkdir test_proj
cd test_proj
mkdir src bin
touch configure.ac Makefile.am



#configure.ac
AC_INIT(src/main.cpp)
AM_INIT_AUTOMAKE(add, 1.0)

AC_PROG_CXX
AC_HEADER_STDC
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)

AC_OUTPUT(Makefile src/Makefile)



#Makefile.am
SUBDIRS = src


cd src
touch main.cpp add.cpp add.h Makefile.am

#Makefile.am
#the output program
bin_PROGRAMS = ADD

AM_CXXFLAGS = $(INTI_CFLAGS)

CFLAGS = -Wall -O2

#ADD_SOURCES, you have to attache ADD_ with the options
ADD_SOURCES = main.cpp add.cpp

#add ld here like lstdc++ etc etc
ADD_LDADD = @LDFLAGS@

#add ld path here,like -L /usr/local/lib
ADD_LDFLAGS =

#add include paths for any other header files with -I switch
INCLUDES =


1
2
3
4
5
6
7
8
9
//main.cpp
#include <stdio.h>
#include "add.h"

int main()
{
        int retval = add(10, 20);
        return 0;
}


1
2
3
4
5
6
7
//add.cpp
#include "add.h"

int add(int x, int y)
{
        return (x + y);
}


1
2
3
4
5
6
7
//add.h
#ifndef __add_h__
#define __add_h_

int add(int x, int y);

#endif 


thats it.. you are dont..
cd ..
aclocal
autoconf --add-missing
automake
./configure //this will create your makefile
make //this will create a binary with name "add"

thats all you need to do.. now if you add any new file to project, just add it to Makefile.am and aclocal to make again.
if autoconf or automake give error for any missing files, create these file using touch. it may give error for INSTALL, COPYING, README, NEWS, depcomp, AUTHORS etc etc.. so create these files manually.










Hi


OK. thanks...
Topic archived. No new replies allowed.