[PATCH] examples: gcc linker requires library depencencies come after they are needed



On modern distributions, ld runs with the '--as-needed' option enabled by
default, meaning library dependencies must come after files that require them.
Also, this allows indirect linking so the build commands can be simplified.

The alternative is to add the '-Wl,--as-needed' gcc option or use the top-level
Makefile.

Tested on:
 * Ubuntu 16.04.2 with gcc Ubuntu 5.4.1-8ubuntu1
 * Fedora 24 with gcc Red Hat 6.1.1-3

Signed-off-by: Lucas Magasweran <lucas magasweran ieee org>
---
 examples/C/glib/add-connection-gdbus.c         | 2 +-
 examples/C/glib/add-connection-libnm.c         | 2 +-
 examples/C/glib/get-active-connections-gdbus.c | 2 +-
 examples/C/glib/get-ap-info-libnm.c            | 2 +-
 examples/C/glib/list-connections-gdbus.c       | 2 +-
 examples/C/glib/list-connections-libnm.c       | 2 +-
 examples/C/glib/monitor-nm-running-gdbus.c     | 2 +-
 examples/C/glib/monitor-nm-state-gdbus.c       | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/examples/C/glib/add-connection-gdbus.c
b/examples/C/glib/add-connection-gdbus.c
index f3b64a0..7c8edf6 100644
--- a/examples/C/glib/add-connection-gdbus.c
+++ b/examples/C/glib/add-connection-gdbus.c
@@ -24,7 +24,7 @@
  * higher level because it uses libnm.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --cflags libnm` `pkg-config --cflags
--libs gio-2.0` -luuid add-connection-gdbus.c -o add-connection-gdbus
+ *   gcc -Wall add-connection-gdbus.c -o add-connection-gdbus
`pkg-config --cflags --libs libnm uuid`
  */

 #include <gio/gio.h>
diff --git a/examples/C/glib/add-connection-libnm.c
b/examples/C/glib/add-connection-libnm.c
index 7b20c9a..86915ea 100644
--- a/examples/C/glib/add-connection-libnm.c
+++ b/examples/C/glib/add-connection-libnm.c
@@ -24,7 +24,7 @@
  * much of the low-level stuff for you.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm`
add-connection-libnm.c -o add-connection-libnm
+ *   gcc -Wall add-connection-libnm.c -o add-connection-libnm
`pkg-config --libs --cflags libnm`
  */

 #include <glib.h>
diff --git a/examples/C/glib/get-active-connections-gdbus.c
b/examples/C/glib/get-active-connections-gdbus.c
index 70bd674..217fd7a 100644
--- a/examples/C/glib/get-active-connections-gdbus.c
+++ b/examples/C/glib/get-active-connections-gdbus.c
@@ -23,7 +23,7 @@
  * a few defines from the NetworkManager headers.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --cflags libnm` `pkg-config --cflags
--libs gio-2.0` get-active-connections-gdbus.c -o
get-active-connections-gdbus
+ *   gcc -Wall get-active-connections-gdbus.c -o
get-active-connections-gdbus `pkg-config --cflags --libs libnm`
  */

 #include <string.h>
diff --git a/examples/C/glib/get-ap-info-libnm.c
b/examples/C/glib/get-ap-info-libnm.c
index 5868c27..a548d12 100644
--- a/examples/C/glib/get-ap-info-libnm.c
+++ b/examples/C/glib/get-ap-info-libnm.c
@@ -22,7 +22,7 @@
  * libnm.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm`
get-ap-info-libnm.c -o get-ap-info-libnm
+ *   gcc -Wall get-ap-info-libnm.c -o get-ap-info-libnm `pkg-config
--libs --cflags libnm`
  */

 #include <glib.h>
diff --git a/examples/C/glib/list-connections-gdbus.c
b/examples/C/glib/list-connections-gdbus.c
index 14a633f..088df1d 100644
--- a/examples/C/glib/list-connections-gdbus.c
+++ b/examples/C/glib/list-connections-gdbus.c
@@ -24,7 +24,7 @@
  * level because it uses libnm.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --cflags libnm` `pkg-config --cflags
--libs gio-2.0` list-connections-gdbus.c -o list-connections-gdbus
+ *   gcc -Wall list-connections-gdbus.c -o list-connections-gdbus
`pkg-config --cflags --libs libnm`
  */

 #include <gio/gio.h>
diff --git a/examples/C/glib/list-connections-libnm.c
b/examples/C/glib/list-connections-libnm.c
index f09c028..5dc3820 100644
--- a/examples/C/glib/list-connections-libnm.c
+++ b/examples/C/glib/list-connections-libnm.c
@@ -23,7 +23,7 @@
  * using GDBus.
  *
  * Compile with:
- *   gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm`
list-connections-libnm.c -o list-connections-libnm
+ *   gcc -Wall list-connections-libnm.c -o list-connections-libnm
`pkg-config --cflags --libs libnm`
  */

 #include <glib.h>
diff --git a/examples/C/glib/monitor-nm-running-gdbus.c
b/examples/C/glib/monitor-nm-running-gdbus.c
index 2e1a11c..c19569b 100644
--- a/examples/C/glib/monitor-nm-running-gdbus.c
+++ b/examples/C/glib/monitor-nm-running-gdbus.c
@@ -25,7 +25,7 @@
  * See also http://developer.gnome.org/gio/stable/gio-Watching-Bus-Names.html
  *
  * Standalone compilation:
- *   gcc -Wall `pkg-config --libs --cflags glib-2.0 gio-2.0`
monitor-nm-running-gdbus.c -o monitor-nm-running-gdbus
+ *   gcc -Wall monitor-nm-running-gdbus.c -o monitor-nm-running-gdbus
`pkg-config --libs --cflags gio-2.0`
  */

 #include <gio/gio.h>
diff --git a/examples/C/glib/monitor-nm-state-gdbus.c
b/examples/C/glib/monitor-nm-state-gdbus.c
index 0559639..913644d 100644
--- a/examples/C/glib/monitor-nm-state-gdbus.c
+++ b/examples/C/glib/monitor-nm-state-gdbus.c
@@ -26,7 +26,7 @@
  * grab nm-dbus-interface.h and put it in the path.
  *
  * Standalone compilation:
- *   gcc -Wall `pkg-config --libs --cflags glib-2.0 gio-2.0`
`pkg-config --cflags libnm` monitor-nm-state-gdbus.c -o
monitor-nm-state-gdbus
+ *   gcc -Wall monitor-nm-state-gdbus.c -o monitor-nm-state-gdbus
`pkg-config --cflags --libs libnm`
  */

 #include <gio/gio.h>
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]