Re: Downgrading from gcc 3.2.1 to gcc 2.96

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

 



On Tue, Oct 14, 2003 at 12:04:42PM +0100, puneet girdhar wrote:
> Hi ,
> I was using following code on gcc 3.2.1 on Linux.
> 
> #include <stdio.h>
> #include <dlfcn.h>
> 
> int main()
> {
>         char dll_name[100];
>         void * handle;
>         //lt_dlhandle hndl;
>         printf("which lib u want to print :");
>         scanf("%s",&dll_name);
>         printf("%s\n",dll_name);
>         handle = dlopen(dll_name,RTLD_LAZY);
>         Dl_info info;
>         void * gotaddr;
>         gotaddr=dlsym(handle,"_GLOBAL_OFFSET_TABLE_");
>         dladdr(gotaddr,&info);
>         printf("value of filename is
> %s\n",info.dli_fname);
>         return 0;
> }
> 
> 
> This code was working fine with gcc 3.2.1. Now i want
> to use this code with gcc 2.96 on linux. But it gives
> the following error:
> 
> a.cpp: In function `int main ()':
> a.cpp:13: `Dl_info' undeclared (first use this
> function)
> a.cpp:13: (Each undeclared identifier is reported only
> once for each 
> function it appears in.)
> a.cpp:13: parse error before `;'
> a.cpp:16: `info' undeclared (first use this function)
> a.cpp:16: `dladdr' undeclared (first use this
> function)

Have you already had a look at the dlfcn.h header file? Dl_info is
only defined when the __USE_GNU preprocessor macro is defined.

It seems GCC 3.x defines this macro when invoked as g++ or if the
source file is identified as c++ code. Otherwise it also doesn't.

-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux