diff --git a/python/setup.py b/python/setup.py
index 2547842..0c68cd8 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -17,14 +17,14 @@ if intree:
     netsnmp_libs = os.popen(basedir+'/net-snmp-config --libs').read()
     libdir = os.popen(basedir+'/net-snmp-config --build-lib-dirs '+basedir).read()
     incdir = os.popen(basedir+'/net-snmp-config --build-includes '+basedir).read() + " " + os.popen(basedir+'/net-snmp-config --base-cflags '+basedir).read()
-    libs = re.findall(r"-l(\S+)", netsnmp_libs)
+    libs = re.findall(r"\s-l(\S+)", netsnmp_libs)
     libdirs = re.findall(r"-L(\S+)", libdir)
     incdirs = re.findall(r"-I(\S+)", incdir)
 else:
     netsnmp_libs = os.popen('net-snmp-config --libs').read()
     libdirs = re.findall(r"-L(\S+)", netsnmp_libs)
     incdirs = []
-    libs = re.findall(r"-l(\S+)", netsnmp_libs)
+    libs = re.findall(r"\s-l(\S+)", netsnmp_libs)
 
 setup(
     name="netsnmp-python", version="1.0a1",
