Difference between revisions of "Gcc"
From Teknologisk videncenter
m (Created page with "=C99= Compile to binary using C99 pedantic preparred for GDB debugging <source lang=bash> $gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE </source>") |
m (→C99) |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
$gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE | $gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE | ||
</source> | </source> | ||
+ | =Finding library gcc options= | ||
+ | Find the necessary '''gcc''' options with '''pkg-config''' - example below. | ||
+ | <source lang=bash> | ||
+ | heth@emb3:~$ pkg-config --libs --cflags dbus-1 | ||
+ | -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1 | ||
+ | heth@emb3:~$ gcc dbus_ex.c -o dbus_ex -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1 | ||
+ | -OR- | ||
+ | heth@emb3:~$ gcc dbus_ex.c -o dbus_ex $(pkg-config --libs --cflags dbus-1) | ||
+ | </source> | ||
+ | |||
+ | [[Category:C]][[Category:Linux]] |
Latest revision as of 10:45, 21 December 2022
C99
Compile to binary using C99 pedantic preparred for GDB debugging
$gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE
Finding library gcc options
Find the necessary gcc options with pkg-config - example below.
heth@emb3:~$ pkg-config --libs --cflags dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
heth@emb3:~$ gcc dbus_ex.c -o dbus_ex -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
-OR-
heth@emb3:~$ gcc dbus_ex.c -o dbus_ex $(pkg-config --libs --cflags dbus-1)