Using separate files in C++


I have a very simple program which I want to separate into different files and Atom gives me the following wrror message

C:\Users\Tyskland\AppData\Local\Temp\ccO5xkY3.o:Main.cpp:(.text+0xc): undefined reference to `hello()’
collect2.exe: error: ld returned 1 exit status.

The program files are:

#include “Output.h”
int main(){
return 0;
#include “Output.h”
using namespace std;
void hello(){
cout << “Hello world!” << endl;

void hello();

How come this simple program is not executed in Atom?


Atom isn’t giving you anything. Atom has no ability to run code. You are using a package to invoke the compiler g++ and the compiler is giving you an error. Based on the path that the compiler returns (C:\Users\Tyskland\AppData\Local\Temp\ccO5xkY3.o:Main.cpp), I’m gathering that the package is creating a temporary file with the contents of main.cpp.

What package are you using and what steps are you following to run your code?


I’m using the gpp-compiler 3.0.7. I’m just running the compiler on Main.cpp with the short command that comes with the compiler.


Open the gpp-compiler settings (Settings -> Packages -> gpp-compiler) and tell me if the setting Compile to Temporary Directory is checked. If so, please uncheck it and try again.


Uncheking it did not solve the problem.


Then you will probably have to ask the package author for more expert help. Unfortunately, it’s an old package that hasn’t been updated in a while, so maybe a better option would be to find a different package. I like process-palette for automating command line instructions.


This post was flagged by the community and is temporarily hidden.