Monday, April 29, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 4583  / 1 Year ago, fri, march 17, 2023, 3:54:43

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

More From » command-line

 Answers
4

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`

[#27682] Sunday, March 19, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bleger

Total Points: 468
Total Questions: 108
Total Answers: 100

Location: Belarus
Member since Wed, Dec 7, 2022
1 Year ago
;