Hello World in C++ Exercise Not Working In Exercism Editor

So I’m trying to complete the first Hello World exercise in C++…I entered the following code:


int main() {
std::cout << “Hello World”;
return 0;

However when clicking the “Run Tests” button, I get the following error:

We received the following error when we ran your code:

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/local/lib64/libCatch2WithMain.a(catch_with_main.cpp.o): in function `main':
catch_with_main.cpp:(.text+0x29535): multiple definition of `main'; CMakeFiles/hello-world.dir/hello_world.cpp.o:/tmp/hello-world/hello_world.cpp:3: first defined here
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: CMakeFiles/hello-world.dir/hello_world_test.cpp.o: in function `____C_A_T_C_H____T_E_S_T____0()':
/tmp/hello-world/hello_world_test.cpp:15: undefined reference to `hello_world::hello[abi:cxx11]()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello-world.dir/build.make:100: hello-world] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/hello-world.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

What’s going on??

For some reason iostream in “<>” isn’t showing up after #include in my post but it’s there.

The tests want you to implement a function that returns something, not a freestanding program that prints something.

Initially the file hello_world.cpp looks like this

#include "hello_world.h"

using namespace std;

namespace hello_world

string hello()
    return "Goodbye, Mars!";


You can see that it already defines the function hello(), but the returned string is wrong. In this first exercise you just have to correct that string.

1 Like

Ah, I overcomplicated the exercise then. Thank you, sir!

1 Like

You’re welcome (both figuratively and here in the forum). Have fun!

1 Like