0

I've written a simple C program that uses the GTK+ visual interface (I can post the code if it's relevant). I can compile it without erros or warnings using:

gcc -c s9p2.c 
pkg-config --cflags glib-2.0
pkg-config --cflags gtk+-2.0

Where s9p2.c is the program name. However, when I try to run the program I get this:

bash: ./s9p2: No such file or directory

I have checked with the ls command and the file is in fact there. I have also tried to install. I have tried googling for a solution, and one that came up was to install the ia32-libs package. I did that, but it did not work.

I would appreciate any help. Please forgive me if I was not clear.

EDIT: As asked, this is the output of ls -l s9p2* is:

-rw-rw-r-- 1 francisco francisco 2492 Jan  3 19:11 s9p2.c
-rw-rw-r-- 1 francisco francisco 6616 Jan  3 21:13 s9p2.o
kiri
  • 28,246
  • 16
  • 81
  • 118
FranciscoS
  • 3
  • 1
  • 3

2 Answers2

1

Your main error is adding the -c flag to your command - that tells gcc to compile the source file (producing an object code file s9p2.o) but stop short of linking it with the libraries necessary to create an executable program (s9p2)

The correct command should be something like

gcc -o s9p2 `pkg-config --cflags glib-2.0` s9p2.c `pkg-config --libs gtk+-2.0`

or

gcc -o s9p2 s9p2.c `pkg-config --cflags --libs gtk+-2.0`
steeldriver
  • 136,215
  • 21
  • 243
  • 336
0

First the c file is not the program, the binary executable which should be called s9p2 (no extension) unless you specified something different which compiling. Assuming you have compiled to an executable you need to make it executable as a program if it is not already:

The file is not executable, try running:

chmod +x s9p2