starting problem

yesterday i installed g++ from the following page.
https://github.com/kennethreitz/osx-gcc-installer
i have a macbook.
and i wrote a very simple skript-code:

#include <iostream>
int main()
{
std::cout << "Hallo, du schöne Welt!";
return 0;
}

now i started g++ with the following command in terminal:
g++ -o runtest ./scriptcode

but nothing happens, only the following text was open.
but i dont understand what g++ mean with the following textoutput

ld: warning: ignoring file ./scriptcode, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

can anybody help me to create my first textoutput application.
thank you so much!!!!!
Rename your file containing

1
2
3
4
5
6
7
#include <iostream>

int main()
{
    std::cout << "Hallo, du schöne Welt!";
    return 0;
}


as scriptcode.cc ( .cc is one of the standard file name extensions used for C++ programs.)

And now, at the command prompt: > g++ -o runtest scriptcode.cc && ./runtest
Last edited on
thanx so much JLBorges

you can even write 2 commands in the terminal-shell
g++ -o runtest scriptcode.cc
and then
./runtest

yeahh yeah yeah i am so happy, i will have fun in writing in c++. thank you again so much :-))
Last edited on
Now that you have gone past the first hurdle, start using

> g++ -std=c++11 -Wall -Wextra -pedantic-errors for compiling your programs.

eg. > g++ -std=c++11 -Wall -Wextra -pedantic-errors -o runtest scriptcode.cc

And look carefully at any diagnostic emitted by the compiler.

If you do so, the compiler will help you a lot in learning C++.

Topic archived. No new replies allowed.