error: ld returned 1 exit status,混合编译找不到c++中的代码原因是cmakelist问题;以及找下混合编译时候cmake版本的选择

您所在的位置:网站首页 java错误找不到符号怎么办 error: ld returned 1 exit status,混合编译找不到c++中的代码原因是cmakelist问题;以及找下混合编译时候cmake版本的选择

error: ld returned 1 exit status,混合编译找不到c++中的代码原因是cmakelist问题;以及找下混合编译时候cmake版本的选择

2023-06-16 07:06| 来源: 网络整理| 查看: 265

注意版本:cmake 3.16Clion:20231.3JDK:sudo apt-get install openjdk-17-jdk

特别推荐: cmake 3.16; clion版本是2022-2.5版本;则JDK版本是: sudo apt-get install openjdk-11-jdk

问题 error: ld returned 1 exit status,混合编译找不到c++中的代码原因是cmakelist问题:

/usr/bin/ld: CMakeFiles/c2cppTest.dir/main.c.o: in function main': /home/feida/CLionProjects/c2cppTest/main.c:9: undefined reference to my_add’ collect2: error: ld returned 1 exit status make[3]: *** [CMakeFiles/c2cppTest.dir/build.make:84: c2cppTest] Error 1 make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/c2cppTest.dir/all] Error 2 make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/c2cppTest.dir/rule] Error 2 make: *** [Makefile:118: c2cppTest] Error 2

解决方法:再cmakelist中的project声明中去掉c关键词就好了

例如:project(test c)修改为:project(test)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3