Linking error: "multiple definitions of `main'"

Open discussion regarding features, bugs, issues, vendors, etc.

Linking error: "multiple definitions of `main'"

Postby mechie » Fri Nov 06, 2009 7:13 pm

When I link my code using the makefile below i get this error:

In function `main':
FLRMA.cpp:(.text+0x1ed8): multiple definition of `main'
/home/mimi/CLAPACK/F2CLIBS/libf2c.a(main.o):(.text+0x0): first defined here
/home/mimi/CLAPACK/F2CLIBS/libf2c.a(main.o): In function `main':
(.text+0xb5): undefined reference to `MAIN__'
collect2: ld returned 1 exit status


I references the main.o in the f2c library. Am I missing something about the way I should set up my linking? I have several module files I link together. Attached below is my main file that calls a function from one of the other files and also the make file I am using. Please let me know if I am doing something wrong.
Thanks,
Mechie
Code: Select all
OBJS = tensor.o submatrix_tensor.o tensor.h
CC = g++
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
#g++ -o main.exe main.cpp -L. -llapack -lblas -lF77 -lI77


ROOTPATH = /home/mimi/CLAPACK
INCDIRS = -I$(ROOTPATH)/SRC -I$(ROOTPATH)
F2CDIR  = $(ROOTPATH)/F2CLIBS
LDLIBS  =-L $(ROOTPATH)/lapack_LINUX.a \
          $(ROOTPATH)/blas_LINUX.a \
          $(F2CDIR)/libf2c.a -lm


FLRMA.o: FLRMA.cpp submatrix_tensor.cpp tensor.cpp tensor.h
   $(CC) $(LFLAGS) FLRMA.cpp  $(LDLIBS) -o FLRTA.o

tensor.o: tensor.cpp tensor.h
   $(CC)  $(CFLAGS) tensor.cpp  $(INCDIRS) -o tensor.o

submatrix_tensor.o: submatrix_tensor.cpp tensor.cpp tensor.h
   $(CC) $(LFLAGS) submatrix_tensor.cpp  $(LDLIBS)  -o submatrix_tensor.o


this is the main file
Code: Select all
using namespace std;

#include "tensor.h"
#include "submatrix_tensor.cpp"
#include "tensor.cpp"

/**********************MAIN FUNCTION*********************/
int main(void){
   //reads data in A and initializes it
   cout<<"I go into main before fault" <<endl;
   A = initmatrix( filename, M, N);
   cout<<"Atleast my matrix was initialized"<<endl;
   display( A, M, N);



return 0;
}


I link with
Code: Select all
  g++ -L /home/mimi/CLAPACK/lapack_LINUX.a /home/mimi/CLAPACK/blas_LINUX.a /home/mimi/CLAPACK/F2CLIBS/libf2c.a -lm -o FLRMA FLRMA.cpp
mechie
 
Posts: 4
Joined: Fri Nov 06, 2009 11:41 am

Re: Linking error: "multiple definitions of `main'"

Postby admin » Fri Nov 13, 2009 11:54 am

Hi mimi,
did you manage to solve your problem?
libf2c has no main inside....maybe you should try to regenerate the f2c library.
Julie
admin
Site Admin
 
Posts: 43
Joined: Wed Dec 08, 2004 7:07 pm


Return to User Discussion

Who is online

Users browsing this forum: MSN [Bot] and 4 guests