--- a/test/test_dl.py
+++ b/test/test_dl.py
@@ -1,5 +1,6 @@
 import mpiunittest as unittest
 import sys, os
+from ctypes.util import find_library
 try:
     from mpi4py import dl
 except ImportError:
@@ -12,10 +13,8 @@
 class TestDL(unittest.TestCase):
 
     def testDL1(self):
-        if sys.platform == 'darwin':
-            libm = 'libm.dylib'
-        else:
-            libm = 'libm.so'
+        # find the system's libm (libm.so on linux or libm.dylib on Darwin)
+        libm=find_library('m')
 
         handle = dl.dlopen(libm, dl.RTLD_LOCAL|dl.RTLD_LAZY)
         if handle == 0 and sys.platform.startswith('linux'):
