Difference between revisions of "Gcc"
From Teknologisk videncenter
m (added Category:C using HotCat) |
m (→C99) |
||
Line 4: | Line 4: | ||
<source lang=bash> | <source lang=bash> | ||
$gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE | $gcc -ggdb -std=c99 -pedantic SOURCE.c -o BINFILE | ||
+ | </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> | </source> | ||
− | [[Category:C]] | + | [[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)