0

Can someone explain to me why this happens? It compiles the program fine but it wont let me run it. I'm on ubuntu 16.04

Bonus question: How can I run the math library on Geany? I love the interface but can't figure out how to to run math.h header file.

Here's the code:

enter image description here

Sam Al
  • 1

1 Answers1

3

Firstly using the gcc switch -c you are telling the compiler to only compile and not link which doesn't produce an executable binary to get an executable binary you need to not use this switch. The correct command would be:

gcc cents.c

However since this command does not specify the output file name the default name a.out will be used for the binary so you probably want to use this command:

gcc cents.c -o cents

Which will produce an executable binary called cents which can then be executed with

./cents

As for your other question you don't run header files that is not their purpose, header files are source code files the same as .c except their job is to be processed by the c preprocessor. Generally they are used to contain function prototypes for libraries to ensure that the same definitions are used throughout the project even if later the function requires a change to the prototype this helps to minimise errors and resulting bugs when changes are made in the program since the risk of someone missing a source file when changing the definition is otherwise high in large projects.

MttJocy
  • 692