Use C++ std::cout in lldb

Viewed 4211

I'm trying to call std::cout within lldb in an Xcode 5 C++ project. My project has an #include <iostream> line (and I verified that compiled std::cout commands work fine), but it does not have a using namespace std; line.

When I stop at a breakpoint in lldb, I can't call std::cout:

(lldb) expr std::cout << "test"
error: no member named 'cout' in namespace 'std'
error: 1 errors parsing expression

(lldb) expr cout << "test"
error: use of undeclared identifier 'cout'
error: 1 errors parsing expression

For those interested, I'm trying to use std::cout to print an OpenCV Mat object. But that detail is probably not important.

My lldb version is lldb-300.2.53.

By request, here's the (trivial) code:

#include <iostream>
int main(int argc, const char * argv[])
{
  std::cout << "Hello World" << std::endl;
  return 0;
}

The breakpoint is at the return 0; line.

3 Answers
Related