编动态链接库时,提示 对‘dlopen’未定义的引用.
我按网上的方法写了个调用LINUX下的动态链接库的代码。代码如下。 
 #include    <iostream>  
 #include    <dlfcn.h>  
 using   namespace   std;   
 int   main() 
 { 
    void   *dp;   
    dp   =   dlopen( "test.so ",RTLD_NOW); 
    if   (dp==NULL) 
    { 
       fputs(dlerror(),stderr); 
       exit(1); 
    }   
    dlclose(dp); 
    return   0; 
 }   
 编译时报错: 
 ../main.cpp:9:对 'dlopen '未定义的引用 
 ../main.cpp:12:对 'dlerror '未定义的引用 
 ../main.cpp:16:对 'dlclose '未定义的引用 
 collect2:   ld   returned   1   exit   status 
 ... 
 ...   
 我用的编程环境   ubunto   +   eclipse3.2   +   cdt3.1.1 
 我用g++编译也是一样的错误. 
 是不是没有引对   dlfcn.h   ,但我设置的时候   也设了的阿...   
 请教高手是什么原因.
------解决方案---------------------ldl 
 === 
 mymtom@fc6:src/csdn/dlopen$ make LDLIBS=-ldl dlopen 
 g++     dlopen.cpp  -ldl -o dlopen 
 mymtom@fc6:src/csdn/dlopen$ cat dlopen.cpp 
 #include  <iostream>  
 #include  <dlfcn.h>  
 using namespace std;   
 int main() 
 { 
         void *dp;   
         dp = dlopen( "test.so ",RTLD_NOW); 
         if (dp==NULL) 
         { 
                 fputs(dlerror(),stderr); 
                 exit(1); 
         }   
         dlclose(dp); 
         return 0; 
 }   
 mymtom@fc6:src/csdn/dlopen$ uname -a 
 Linux fc6.unix-center.net 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:39:22 EDT 2006 x86_64 
 mymtom@fc6:src/csdn/dlopen$
------解决方案--------------------make file 加上 -ldl