【发布时间】:2020-01-04 13:35:31
【问题描述】:
我已经为 Eclipse-CDT 启用了漂亮的打印。这是我之前的问题:Enable pretty printing in Eclipse C++
我已完成上一个问题中提到的所有步骤。我意识到漂亮的打印确实适用于简单的测试程序,但不适用于我的项目。因此,我提出了一个新问题,因为这似乎是特定于项目的设置。
这是我的设置:
- Eclipse 版本:2018-09 (4.9.0)
- gdb 7.11.1
- Xubuntu 16.04
- gcc 7.4.0
- g++ 7.4.0
我有一个简单的 test.cpp
#include <map>
#include<vector>
int main() {
std::map<char, int> first;
first['a'] = 10;
first['b'] = 20;
std::vector<int> a{1,2,3,4,5};
}
我使用 New > Makefile Project with Existing Code 将它导入 Eclipse,在终端中编译它: g++ -g -o test test.cpp
然后我在 Eclipse 中调试了这个程序并得到了这个:
Name : first
Details:std::map with 1 element = {[97 'a'] = 10}
Default:{...}
Decimal:{...}
Hex:{...}
Binary:{...}
Octal:{...}
对于这个简单的测试用例,Eclipse-CDT 中的打印效果非常好。我假设 Eclipse > Windows > Preferences 中的任何设置都设置得很好。
对于我的另外两个项目(其中一个使用https://github.com/Svalorzen/AI-Toolbox),我将test.cpp中的代码sn-p粘贴到main.cpp中,在Eclipse中使用make和项目特定的CMakeLists编译它,调试它得到了这个:
对于其中一个项目:
Name : first
Details:{_M_t = {_M_impl = {<No data fields>}}}
Default:{...}
Decimal:{...}
Hex:{...}
Binary:{...}
Octal:{...}
对于其他项目:
Multiple errors reported.
1) Failed to execute MI command:
-var-create - * first
Error message from debugger back end:
Null value returned for children
2) Unable to create variable object
3) Failed to execute MI command:
-var-create - * first
Error message from debugger back end:
Null value returned for children
我已经检查了所有 3 种情况的调试配置 > 调试器,并且设置是相同的。有谁知道我为什么会收到这些错误?
我猜我可能需要修改 CMakeLists,但我没有足够的知识来解决这个问题。这是我的两个项目的 CMakeLists 的 sn-p:
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
完整的 CMakeLists 在这里 https://github.com/Svalorzen/AI-Toolbox/blob/master/CMakeLists.txt
【问题讨论】:
标签: c++ eclipse eclipse-cdt