我有一个header1.h包含在raster2d.h中,然后raster2d.h包含在io.cpp和raster2d.cpp中。当我编译时,我得到以下链接器错误`
g++ -g -I. -I/opt/local/include -o raster2d.o -c raster2d.cpp
g++ -g -I. -I/opt/local/include -o stb.o -c stb.cpp
g++ -g -I. -I/opt/local/include -o io.o -c io.cpp
g++ -o raster2d raster2d.o SimpleImage.o stb.o io.o -L/opt/local/lib
duplicate symbol __ZN9Transform14multiplicationE6Matrix in:
raster2d.o
io.o
duplicate symbol __ZN9Transform5scaleEP7Point2fff in:
raster2d.o
io.o
duplicate symbol __ZN9Transform6rotateEP7Point2ff in:
raster2d.o
io.o
duplicate symbol __ZN9Transform9translateEP7Point2fff in:
raster2d.o
io.o
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [raster2d] Error 1
Transform是header.h中的一个类 Transform :: translate Transform :: scale& Transform :: rotate是header1.h
中的三个函数