This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/TMS320F28335:适用于 C2000编译器的 CMake 项目

Guru**** 2553260 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/892614/compiler-tms320f28335-cmake-project-for-c2000-compiler

器件型号:TMS320F28335

工具/软件:TI C/C++编译器

您好!

我正在尝试使用 CMake 交叉编译一个简单的项目。 我设置了一个非常简单的项目、其中包含一个库和一个可执行文件。 我想编译库、然后在可执行文件中链接它。

目前我遇到的问题是、我创建的库不导出任何符号。

为了测试我所做的操作是否正确、我首先在 CCS 中创建了一个静态库工程和一个可执行工程。 一切都很好。 为了让我测试 CMake 生成的库、我尝试将 CMake 生成的库与 CCS 中的可执行文件链接起来、并得到错误消息:

警告#10189-D:未

定义存档"libprintTest.a"中缺少存档符号目录 第一
个引用的符号 文件中
------ --------
PrintTest::PrintTest()./main.obj
PrintTest:::~PrintTest()./main.obj
PrintTest::doit() /main.obj

错误#10234-D:未解析的符号仍然
存在错误#10010:链接期间遇到错误;未生成"test.out" 

有什么想法吗?

我已附加我的 CMake 测试项目。 要运行它、只需安装 CMake (https://cmake.org)

CD /build
cmake -dcdmake_verbose_Makefile:BOOL=on。
制造 

当前编译输出为:

-- CGT_toolchain_DIR 未明确设置,使用/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS
-- C 编译器标识是 TI 20.2.0
-- CXX 编译器标识是 TI 20.2.0
--检查工作中的 C 编译器:/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000
--检查工作中的 C 编译器:/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 --工作
中--检测 C 编译器 ABI 信息
-- 检测 C 编译器 ABI 信息-完成
了--检查 CXX 编译器是否正常工作:/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000
--检查 CXX 编译器是否正常工作:/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 --工作
--检测 CXX 编译器 ABI 信息
--检测 CXX 编译器 ABI 信息--完成
了--在启用错误时处理警告
--配置完成
-- 生成完成
--生成文件已写入:/Users/Rafa/Documents/workspace/cmakeTest/build
build Rafa$ make
/Applications/CMake.app/Contents/bin/cmake -S/users/Rafa/documents/workspace/cprintTest -B/users/Rafa/documents/workspace/cmakedTest/build --check-build-system cmakeFiles/Makeefile.cmake 0
/Applications/CMake.app/Contents/bin/cmake


/Users/Rafa/Documents/workspace/cmakeTest/build -e cmake_progress_start /Users/Rafa/Documents/workspace/cmakeTest/build/CMakeFiles /Users/Rafa/Documents/workspace/cmakeTest/build/CMakeFiles/progress.marks /Applications/Xcode.app/Contents/Developer/usr/bin/make /Applications/CMake.app/Contents/bin/cmake -f CMmakedire//Applications/Xcode.app/Contents/Developer/usr/bin/make -makedirt/makedirtese//Users/Rafa/Documents/workspace/cmakeTest /Users/Rafa/Documents/workspace/cmakeTest/src /Users/Rafa/Documents/workspace/cmakeTest/build /Users/Rafa/Documents/workspace/cmakeTest/build/src /Users/Rafa/Documents/workspace/cmakeTest/build/src/CMakeFiles/printTest.dir/DependInfo.cmake --maked/makedirture/maked/makedirtese/makedese---maked/makedirtese.ree.r&cmmaked/makedirtese/maked/maked/maked.c 文件- color=
扫描目标 printTest
的依赖项/Applications/Xcode.app/Contents/Developer/usr/bin/make -f src/CMakeFiles/printTest.dir/build.make src="/CMakeFiles\printTest.dir/build[25%]
生成 CXX 对象 src="/CMtfiles/printTest.dir/printest.cpp.obj
/Users/Rafa/Documents/workspace/cmakeTest/build/src /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include &/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include/stlport --compile_file=/Users/Rafa/Documents/workspace/cmakeTest/src/printtest.cpp --dove=-display-off-off-=-32=-off-off-off-display-off-off-off---off--dify_bot=/Users/Rafa/Documents/workspace/cmakeTest/src -display=-off-off-off-off-off-off-ep-off-off-display-off-off-off-off-f=-ine-dag=-ine-dim=-off-off-f=-off-off-f=-off-off-off-off-off-f=-ine-dag=- output_file=cmakeFiles/printTest.dir/printtprintest.cpp.obj
[50%]链接 CXX 静态库 libprintTest.a
CD /Users/Rafa/Documents/workspace/cmakeTest/build/src &&/Applications/CMake.app/Contents/bin/cmake -P cmakeFiles/printTest.dir/cmake_clear_target.cmake
CD /Users/Rafa/Documents/workspace/cmakeTest/build/src &&/Applications/CMake.app/Contents/bin/cmake



/usr/bin/ranlib -E cmake_link_script cmakeFiles/printTest.dir/link.txt -
'printTest.dir=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib -/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/ar2000 -printr.prise.prise.t.obj =--unicle.printr.printr.prue.prue.prue.prue.prue.prue.prue.pru.pru.pru.pru.pru.pru.pru.pru.pru.pru.pru.prue. libprintTest.a 目录为空(库中没有目标文件成员定义全局符号)
[50%]内置目标 printTest
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f example/cmakeFiles/printTestExample.dir/build.make example/cmakeFiles/printTestExample.dir/depend
CD /Users/Rafa/Documents/workspace/cmakeTest/build &&/Applications/CMake.app/Contents/bin/cmake -E cmake_depends "Unix Makefiles"/Users/Rafa/Documents/workspace/cmakeTest /Users/Rafa/Documents/workspace/cmakeTest/example /Users/Rafa/Documents/workspace/cmakeTest/build /Users/Rafa/Documents/workspace/cmakeTest/build/example /Users/Rafa/Documents/workspace/cmakeTest/build/example/CMakeFiles/printTestExample.dir/DependInfo.cmake -- color=
扫描目标 printTestExample
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f example/cmakeFiles/printTestExamExample.dir/build.make example/cmakeFiles/printTestExample.dir/build
[75%]生成 CXX 对象 example/cmakeFiles/printTestExample.cpp/main.abi.obj
cd /Users/Rafa/Documents/workspace/cmakeTest/build/example /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include &&/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include/stlport --compile_-example.dir=-cep-wer=/Users/Rafa/Documents/workspace/cmakeTest/example/main.cpp -off-support=-cep-fate-fate-=-cep-c=-off-status_-ine-fot=-off---ine-fot=-=/Users/Rafa/Documents/workspace/cmakeTest/src -p=-p=-fot_bot_bot=-23=-off-display-p=-p=-f=-pf-n=-display-f-s=-pf-nate-f-s=-p=-display- output_file=cmakeFiles/printTestExample.dir/main.cpp.obj
[100%]链接 CXX 可执行文件 printTestExampleCD
/Users/Rafa/Documents/workspace/cmakeTest/build/example &&/Applications/CMake.app/Contents/bin/cmake
/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/lib -e cmake_link_script cmakeFiles/printTestExamample.dir/link.txt /Applications/ti/c2000/C2000Ware_3_01_00_00/device_support/f2833x/headers/cmd --verbos=1 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/c2000/C2000Ware_3_01_00_00/device_support/f2833x/common/cmd --run_linker --output_file=printTestExbs-map_out_library=-out-ram_ram_ram_s=out-out-out-out-out-out-line-ram_library-out-out-out-out-ram_ram_ram_library-out-out-out-out-out-out-out-out-out-out-out-out-ram_ram_ram_ram_ram_library-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-out-

错误:找不到文件"printtest"
警告#10211-D:无法将/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/lib/libc.a 归档到兼容的库、因为未遇到输入文件
警告#10062-D:入口点符号"_c_int00"未定义
错误#10010:链接期间遇到错误;"printTestExample"未构建

>>编译失败
make[2]:***[example/print1]:
错误: ***[Example/CMakeFiles/printTestExample.dir/all]错误2
make:***[All]错误2 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我忘记了将项目添加为附件。 现已附上。

    e2e.ti.com/.../cmakeTest.zip

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我不熟悉 CMake、也不知道 TI 提供的有关如何集成 CMake 和 TI 编译器工具的任何示例或其他材料。   

    但在本例中、我确实看到了两个问题。  一个...

    [引用 user="Rafael Andrioli Bauer1"]/usr/bin/ranlib libprintTest.a[/quot]

    不要对 AR2000命令创建的库运行 ranlib。   

    第二,链接器调用的参数之一是...

    [引用用户="Rafael Andrioli Baier1]--library=printest[/quot]

    这需要为--library=libprintTest.a.  TI ARM 链接器不使用 GCC 和其他类似 Unix 的链接器使用的库命名约定。

    谢谢、此致、

    乔治

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    非常感谢您的快速回复。

    正如您所说、我已经完成了更改、现在库按预期工作(我已经通过将其链接到 CSS 中生成的可执行文件进行了测试)、但我还无法从 CMake 创建可执行文件。 我还在研究它、尝试找出原因、但我可以发布它、也许您有建议。 我将获得以下输出:

    扫描目标 printTest
    /Applications/Xcode.app/Contents/Developer/usr/bin/make -f src/CMakeFiles\printTest.dir/build.make src="/CMakeFiles\printTest.dir/building.make sc/cmakeFiles\printTest.dir/printtest.dir/printttest.cpp.obj
    
    cd /Users/Rafa/Documents/workspace/cmakeTest/build/src &/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include/stlport --compile_file=/Users/Rafa/Documents/workspace/cmakeTest/src/printtest.cpp /Users/Rafa/Documents/workspace/cmakeTest/src --include_display=-off-off--=/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include -usep-out_ipt=-display-off-cpp -us=-cpu=-cpu=-off-cpu=-cpu-us-cpu-id-off-cpu-cpu-cpu-cpu-a=-cpu-off-cpu-cpu-cpu-cpu-cpu-off-cpu-cpu-cpu-cpu-ep-cpu-cpu-cpu-cpu-off- output_file=cmakeFiles/printTest.dir/printtest.cpp.obj
    [50%]链接 CXX 静态库 libprintTest.a
    CD /Users/Rafa/Documents/workspace/cmakeTest/build/src &&/Applications/CMake.app/Contents/bin/cmake -P cmakeFiles/printTest.dir/cmake_clean_target.cmake
    CD /Users/Rafa/Documents/workspace/cmakeTest/build/src &&/Applications/CMake.app/Contents/bin/cmake -E cmake_link_script cmakeFiles/printTest.dir/link.txt -- verbos=1
    /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/ar2000
    
    
    
    
    /Applications/CMake.app/Contents/bin/cmake -r libprintTest.a cmakeFiles/printTest.dir/printtest.cpp.obj =>新存档'libprintTest.a'=>编译存档'libprintTest.a'[50%]生成目标 printTest /Applications/Xcode.app/Contents/Developer/usr/bin/make /Users/Rafa/Documents/workspace/cmakeTest /Users/Rafa/Documents/workspace/cmakeTest/example /Users/Rafa/Documents/workspace/cmakeTest/build /Users/Rafa/Documents/workspace/cmakeTest/build/example /Users/Rafa/Documents/workspace/cmakeTest/build/example/CMakeFiles/printTestExample.dir/DependInfo.cmake -f example/cmprintFiles/printTestExample.dir/build.make example/cmMake&cakeFiles&ducreus&tres/Cles&cludes /Users/Rafa/Documents/workspace/cmakeTest/build color=
    扫描目标 printTestExample
    /Applications/Xcode.app/Contents/Developer/usr/bin/make -f example/cmakeFiles/printTestExamExample.dir/build.make example/cmakeFiles/printTestExample.dir/build
    [75%]生成 CXX 对象 example/cmakeFiles/printTestExample.cpp/main.abi.obj
    cd /Users/Rafa/Documents/workspace/cmakeTest/build/example /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include &&/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/include/stlport --compile_-example.dir=-cep-wer=/Users/Rafa/Documents/workspace/cmakeTest/example/main.cpp -off-support=-cep-fate-fate-=-cep-c=-off-status_-ine-fot=-off---ine-fot=-=/Users/Rafa/Documents/workspace/cmakeTest/src -p=-p=-fot_bot_bot=-23=-off-display-p=-p=-f=-pf-n=-display-f-s=-pf-nate-f-s=-p=-display- output_file=CMakeFiles/printTestExample.dir/main.cpp.obj
    [100%]链接 CXX 可执行文件 printTestExamExample
    CD /Users/Rafa/Documents/workspace/cmakeTest/build/example &&/Applications/CMake.app/Contents/bin/cmake -e cmake_link_script CMakeFiles/printTestExamample.dir/link.txt
    /Applications/ti/c2000/C2000Ware_3_01_00_00/device_support/f2833x/headers/cmd --verbos=1 /Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/bin/cl2000 /Applications/ti/c2000/C2000Ware_3_01_00_00/device_support/f2833x/common/cmd --run_linker --output_file=printTestExbs-map_example.tinc.intrack=/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/lib -out_s=/src/libprintTest.a -out_ram_ram_ram_ram_s=ines=-out_ram_library-out-out_ram_ram_ram_s=ines=-out-out_ram_ram_ram_ram_ram_ram_ram_out.ines=ines=ines=-out.ip.ip.ines=ines=ines=-out-out.ipc.ines=insp.ipc.insp=insp=insp.ipc.insp.ipc.insp=insp=insp.ipc.insp=insp.
    
    警告#10211-D:无法将/Applications/ti/ccs930/ccs/tools/compiler/ti-cgt-c2000_20.2.0.LTS/lib/libc.a 存档到兼容库、因为未遇到输入文件
    警告#10062-D:入口点符号"_c_int00"未定义
    [100%]已构建目标 printTestExample
    /Applications/CMake.app/Contents/bin/cmake -E cmake_progress_start /Users/Rafa/Documents/workspace/cmakeTest/build/CMakeFiles 0
    

    非常感谢、此致、

    拉斐尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我添加了另一个要链接的库。 它是  rts2800_fpu32.lib。 它不再提供任何编译器或链接错误。 我将尝试在微处理器中对其进行刷写、以检查其是否正常工作。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    更好的解决方案是移动此链接器输入...

    [引用用户="Rafael Andrioli Bauer1]-llibc.a

    (笑声) 链接器调用的最末尾。  然后、链接器会根据链接前面看到的目标文件中的构建属性自动选择要使用的最佳 RTS 库。

    谢谢、此致、

    乔治