我想将一些c ++文件添加到我的C项目中。 如果我在项目中添加多个c ++文件,则在链接时会出现以下错误。
obj/main.o: In function `std::abs(long)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\bits/std_abs.h:56: multiple definition of `std::abs(long)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\bits/std_abs.h:56: first defined here
obj/main.o: In function `std::abs(long long)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\bits/std_abs.h:61: multiple definition of `std::abs(long long)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\bits/std_abs.h:61: first defined here
makefile:156: recipe for target 'bin/evumgnt.elf' failed
obj/main.o: In function `std::div(long, long)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cstdlib:171: multiple definition of `std::div(long, long)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cstdlib:171: first defined here
obj/main.o: In function `__gnu_cxx::div(long long, long long)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cstdlib:208: multiple definition of `__gnu_cxx::div(long long, long long)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cstdlib:208: first defined here
obj/main.o: In function `__gnu_cxx::__is_null_pointer(decltype(nullptr))':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\ext/type_traits.h:163: multiple definition of `__gnu_cxx::__is_null_pointer(decltype(nullptr))'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1\ext/type_traits.h:163: first defined here
obj/main.o: In function `std::frexp(float, int*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:301: multiple definition of `std::frexp(float, int*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:301: first defined here
obj/main.o: In function `std::frexp(long double, int*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:305: multiple definition of `std::frexp(long double, int*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:305: first defined here
obj/main.o: In function `std::modf(float, float*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:377: multiple definition of `std::modf(float, float*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:377: first defined here
obj/main.o: In function `std::modf(long double, long double*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:381: multiple definition of `std::modf(long double, long double*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:381: first defined here
obj/main.o: In function `std::remquo(float, float, int*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:1734: multiple definition of `std::remquo(float, float, int*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:1734: first defined here
obj/main.o: In function `std::remquo(long double, long double, int*)':
c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:1738: multiple definition of `std::remquo(long double, long double, int*)'
obj/sys_init.o:c:\ac6\systemworkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.16.0.201807130628\tools\compiler\arm-none-eabi\include\c++\7.2.1/cmath:1738: first defined here
要编译C文件,我使用arm-none-eabi-gcc,对于C ++文件,我使用arm-none-eabi-g ++。对于链接,我也使用arm-none-eabi-g ++。 我锁定了头文件,并且多个定义的函数是内联函数。问题从哪里来?
答案 0 :(得分:1)
我在makefile cflags中发现了问题,该问题是标志-D inline=