As the question says, I am having trouble seeing std::out statements in the eclipse console when using the "c/c++ unit" run configuration with boost.test.
Here is a simple example describing the issue.
quickEclipse_stdout.cpp:
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "I see this in the eclipse console!\n";
std::cout << "I also see this in the terminal!\n";
return(0);
}
quickEclipse_stdout_test.cpp:
#include <iostream>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(quickTest_stdout)
BOOST_AUTO_TEST_CASE(bla)
{
std::cout << "I cannot see this in the eclipse console" << std::endl;
std::cout << "but I can see it when run outside eclipse in terminal" << std::endl;
BOOST_CHECK_MESSAGE(true, "of course I see this in eclipse c/c++ test log");
}
BOOST_AUTO_TEST_SUITE_END()
I used cmake to generate project files for eclipse.
CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(quickTest CXX)
FIND_PACKAGE(Boost COMPONENTS program_options filesystem regex unit_test_framework)
IF (Boost_FOUND)
MESSAGE("Boost found!!!")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()
#main output to console works
ADD_EXECUTABLE(quickEclipse_stdout, quickEclipse_stdout.cpp)
#boost.test output to console doesnt work
ADD_EXECUTABLE(quickEclipse_stdout_test UTDriver.cpp quickEclipse_stdout_test.cpp)
TARGET_LINK_LIBRARIES(quickEclipse_stdout_test ${Boost_LIBRARIES})
UTDriver.cpp:
#define BOOST_TEST_MODULE myQuickEclipseUT
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
To generate the eclipse project I run the following command:
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.3 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_ARG1=-std=c++11 ~/mySrcDir
- I open the project in eclipse and enter c++ perspective
- I then build the executables by double-clicking on make targets (quickEclipse_stdout, quickEclipse_stdout_test)
- I goto run configurations and create "c/c++ application" for quickEclipse_stdout.
- I goto run configurations and create "c/c++ unit" for quickEclipse-stdout_test and select boost as the test runner.
- I run quickEclipse_stdout and see the output in eclipse console.
- I run quickEclipse_stdout_test and the eclipse console is empty. I see the message in the c/c++ unit messages tab.
- I can see the std::out on both if I run the executables in a terminal outside eclipse.
How can I get the std::out to show in the eclipse console when running the quickEclipse_stdout_test?
I am on Linux CentOS 6.5.
Eclipse Standard/SDK Version: Kepler Service Release 1 Build id: 20130919-0819
Eclipse C/C++ Development Tools Version: 8.2.1.201309180223