c++geany

"./main: not found" (C++, RP 3/B, Geany IDE)


I'm attempting to write a simple program that calls a function written in a pair of Header and CPP files.

I'm doing this on a Raspberry Pi 3 Model B, and the Geany IDE v1.37.1.

Compile Command:

g++ -Wall -c "%f" -c test.cpp

Build Command:

g++ -Wall -o "%e" "%f" -o test test.cpp

main.cpp:

#include "test.h"

int main()
{
    test_function();
    
    return 0;
}

test.h:

#ifndef _test_h_
#define _test_h_

#include <iostream>

void test_function();

#endif

test.cpp:

#include "test.h"

void test_function()
{
    std::cout << "hello world";
}

The code above compiles & builds fine, however attempting to run it yields the following error:

./main: not found

(program exited with code: 127)

Perhaps I am messing something up with the Compile & Build Commands?

Thank you for reading my post, any guidance is apprecaited!


Solution

  • Notice the compile command:

    -o test

    This means that the output binary will be test, so you can execute the application in your terminal or shell via ./test.