Reputation:
When running my makefile I get the following error: I have read that this could be cause by putting the same name twice in the makefile, but I think I didnt. Without the flag it compiles and links without problems.
hmatrices: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o:/build /buildd/glibc-2.21/csu/../sysdeps/x86_64/start.S:63: first defined here
hmatrices: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o:/build /buildd/glibc-2.21/csu/../sysdeps/x86_64/crti.S:80: first defined here
hmatrices:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: (.rodata.cst4+0x0): first defined here
hmatrices: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: (.data+0x0): first defined here
hmatrices: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o:(.data+0x0): first defined here
hmatrices: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o:/build/buildd/glibc-2.21/csu/../sysdeps/x86_64/crti.S:64: first defined here
DataModule.o:(.data+0x0): multiple definition of `__datamodule_MOD_maxerror'
hmatrices:(.data+0x10): first defined here
InputOutputModule.o: In function `__inputoutputmodule_MOD_writematrix':
InputOutputModule.f90:(.text+0x0): multiple definition of `__inputoutputmodule_MOD_writematrix'
hmatrices:(.text+0xf6): first defined here
InputOutputModule.o: In function `__inputoutputmodule_MOD_readmatrix':
InputOutputModule.f90:(.text+0x1c57): multiple definition of `__inputoutputmodule_MOD_readmatrix'
hmatrices:(.text+0x1d4d): first defined here
TestIOModule.o: In function `__testiomodule_MOD_testio':
TestIOModule.f90:(.text+0x0): multiple definition of `__testiomodule_MOD_testio'
hmatrices:(.text+0x2f63): first defined here
HelpModule.o: In function `__helpmodule_MOD_printhelpargument':
HelpModule.f90:(.text+0x0): multiple definition of `__helpmodule_MOD_printhelpargument'
hmatrices:(.text+0x3158): first defined here
HelpModule.o: In function `__helpmodule_MOD_printhelp':
HelpModule.f90:(.text+0x98): multiple definition of `__helpmodule_MOD_printhelp'
hmatrices:(.text+0x31f0): first defined here
MathModule.o: In function `__mathmodule_MOD_solve':
MathModule.f90:(.text+0x0): multiple definition of `__mathmodule_MOD_solve'
hmatrices:(.text+0x326a): first defined here
MathModule.o: In function `__mathmodule_MOD_svd':
MathModule.f90:(.text+0x475): multiple definition of `__mathmodule_MOD_svd'
hmatrices:(.text+0x36df): first defined here
MathModule.o: In function `__mathmodule_MOD_matrixproduct':
MathModule.f90:(.text+0x15a2): multiple definition of `__mathmodule_MOD_matrixproduct'
hmatrices:(.text+0x480c): first defined here
MathModule.o: In function `__mathmodule_MOD_matprod':
MathModule.f90:(.text+0x1d26): multiple definition of `__mathmodule_MOD_matprod'
hmatrices:(.text+0x4f90): first defined here
MathModule.o: In function `__mathmodule_MOD_full':
MathModule.f90:(.text+0x2e3e): multiple definition of `__mathmodule_MOD_full'
hmatrices:(.text+0x60a8): first defined here
TestMathModule.o: In function `__testmathmodule_MOD_testmath':
TestMathModule.f90:(.text+0xa4c): multiple definition of `__testmathmodule_MOD_testmath'
hmatrices:(.text+0x6ddd): first defined here
EquationModule.o: In function `__equationmodule_MOD_plotfield':
EquationModule.f90:(.text+0x8f8): multiple definition of `__equationmodule_MOD_plotfield'
hmatrices:(.text+0x76ea): first defined here
EquationModule.o: In function `__equationmodule_MOD_solveintfull':
EquationModule.f90:(.text+0x1695): multiple definition of `__equationmodule_MOD_solveintfull'
hmatrices:(.text+0x8487): first defined here
EquationModule.o: In function `__equationmodule_MOD_makegfull':
EquationModule.f90:(.text+0x1eb7): multiple definition of `__equationmodule_MOD_makegfull'
hmatrices:(.text+0x8ca9): first defined here
LowRankModule.o: In function `__lowrankmodule_MOD_lowrank':
LowRankModule.f90:(.text+0x10c9): multiple definition of `__lowrankmodule_MOD_lowrank'
hmatrices:(.text+0xa118): first defined here
TestLRModule.o: In function `__testlrmodule_MOD_testlr':
TestLRModule.f90:(.text+0x0): multiple definition of `__testlrmodule_MOD_testlr'
hmatrices:(.text+0xa32e): first defined here
TestModule.o: In function `__testmodule_MOD_constructiontests':
TestModule.f90:(.text+0x47b2): multiple definition of `__testmodule_MOD_constructiontests'
hmatrices:(.text+0xeaff): first defined here
TestModule.o: In function `__testmodule_MOD_test':
TestModule.f90:(.text+0x47c2): multiple definition of `__testmodule_MOD_test'
hmatrices:(.text+0xeb0f): first defined here
Main.o: In function `main':
Main.f90:(.text+0xbb5): multiple definition of `main'
hmatrices:(.text+0xf7b2): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
hmatrices:(.data+0x18): first defined here
/usr/bin/ld: error in hmatrices(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
Makefile:14: recipe for target 'hmatrices' failed
make: *** [hmatrices] Error 1
Here is my make file
# Makefile for "TWS: Project H-matrices: part 1"
####
# Variable for the selected compiler.
FC = gfortran
# Compiler flags:
# -Not needed yet-
FFLAGS=
# Linking step:
hmatrices: DataModule.o InputOutputModule.o TestIOModule.o HelpModule.o MathModule.o TestMathModule.o EquationModule.o LowRankModule.o TestLRModule.o TestModule.o Main.o
$(FC) -o -fbounds-check hmatrices DataModule.o InputOutputModule.o TestIOModule.o HelpModule.o MathModule.o TestMathModule.o EquationModule.o LowRankModule.o TestLRModule.o TestModule.o Main.o -L/usr/local/lib -llapack -lblas
# Compilation step:
# -f.90 files bevinden zich in src-
DataModule.o: ./src/DataModule.f90
$(FC) -c ./src/DataModule.f90
TestIOModule.o: ./src/TestIOModule.f90
$(FC) -c ./src/TestIOModule.f90
HelpModule.o: ./src/HelpModule.f90
$(FC) -c ./src/HelpModule.f90
TestModule.o: ./src/TestModule.f90
$(FC) -c ./src/TestModule.f90
InputOutputModule.o: ./src/InputOutputModule.f90
$(FC) -c ./src/InputOutputModule.f90
MathModule.o: ./src/MathModule.f90
$(FC) -c ./src/MathModule.f90
TestMathModule.o: ./src/TestMathModule.f90
$(FC) -c ./src/TestMathModule.f90
EquationModule.o: ./src/EquationModule.f90
$(FC) -c ./src/EquationModule.f90
LowRankModule.o: ./src/LowRankModule.f90
$(FC) -c ./src/LowRankModule.f90
TestLRModule.o: ./src/TestLRModule.f90
$(FC) -c ./src/TestLRModule.f90
Main.o: ./src/Main.f90
$(FC) -c ./src/Main.f90
# Deze lijn maakt het mogelijk om "make clean" te gebruiken.
clean:
rm -f -r *.o *.mod
# Om de compilatie te forceren wanneer hmatrices reeds bestaat.
.PHONY: hmatrices
Upvotes: 1
Views: 507
Reputation: 80921
I believe your compilation command is incorrect.
I suspect that you compiled hmatrices
manually at one point (or with an earlier makefile) and currently have it in your directory?
Your compilation command is $(FC) -o -fbounds-check hmatrices ...
but that splits the -o
option from its hmatrices
argument. So you are telling $(FC)
to create the -fbounds-check
binary and to link in all your .o
files and the pre-existing hmatrices
binary. Which is where the duplicate symbols are coming from.
Fix your argument order and you'll fix your problem.
That said this makefile isn't taking advantage of many of the features make offers. It can be simplified to the following.
# Makefile for "TWS: Project H-matrices: part 1"
####
# Variable for the selected compiler.
FC = gfortran
# Compiler flags:
# -Not needed yet-
FFLAGS=
# Linking step:
hmatrices: DataModule.o InputOutputModule.o TestIOModule.o HelpModule.o MathModule.o TestMathModule.o EquationModule.o LowRankModule.o TestLRModule.o TestModule.o Main.o
$(FC) -fbounds-check -o $@ $^ -L/usr/local/lib -llapack -lblas
# Compilation step:
# -f.90 files bevinden zich in src-
%.o: ./src/%.f90
$(FC) -c $<
# Deze lijn maakt het mogelijk om "make clean" te gebruiken.
clean:
rm -f -r *.o *.mod
Note that I also removed the .PHONY: hmatrices
line because that is incorrect. You do not want hmatrices
being a phony target. You want it treated as a normal target. (So make only rebuilds it when necessary and not every time the target is hit.)
Upvotes: 1