[CMake] CHECK_FUNCTION_EXISTS(UuidCreate HAVE_UUIDCREATE)

Bill Hoffman bill.hoffman at kitware.com
Mon May 5 16:53:19 EDT 2008


Mathieu Malaterre wrote:
> On Mon, May 5, 2008 at 9:21 PM, Mathieu Malaterre
> <mathieu.malaterre at gmail.com> wrote:
>> On Mon, May 5, 2008 at 9:10 PM, Mathieu Malaterre
>>
>> <mathieu.malaterre at gmail.com> wrote:
>>  >
>>
>>
>>> On Mon, May 5, 2008 at 8:59 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
>>  >  > Mathieu Malaterre wrote:
>>  >  >
>>  >  >
>>  >  > >
>>  >  > > -> that's exactly what is driving me nuts, CheckFunctionExists.c is a
>>  >  > > 5 line c code, it forward declare the function but does not include
>>  >  > > *anything*.
>>  >  > >
>>  >  >  That is what concerns me, it does not include anything.  It maybe required
>>  >  > to include something to find the symbol...
>>  >  >
>>  >  >
>>  >  > >
>>  >  > > And I can confirm that compilation by hand works:
>>  >  > >
>>  >  > >  /usr/local/bin/gcc.exe  -DCHECK_FUNCTION_EXISTS=UuidCreate   -o foo.o
>>  >  > >  -c /usr/share/cmake-2.4.8/Modules/CheckFunctionExists.c
>>  >  > >
>>  >  > > ...
>>  >  > >
>>  >  > >
>>  >  >  Use debug-trycompile.
>>  >  >
>>  >  >  Then cd into the directory and run make, what is different than what works?
>>  >
>>  >  no :(
>>  >
>>  >  If that help here is the nm dump of rpcrt4:
>>  >
>>  >  $ nm /lib/w32api/librpcrt4.a | grep UuidCre
>>  >  00000000 T _UuidCreateSequential at 4
>>  >  00000000 I __imp__UuidCreateSequential at 4
>>  >  00000000 T _UuidCreateNil at 4
>>  >  00000000 I __imp__UuidCreateNil at 4
>>  >  00000000 T _UuidCreate at 4
>>  >  00000000 I __imp__UuidCreate at 4
>>  >  00000000 T _I_UuidCreate at 4
>>  >  00000000 I __imp__I_UuidCreate at 4
>>  >
>>  >  So it's definitely there.
>>  >
>>  >  And grep in /usr/include/w32api, I get:
>>  >
>>  >  rpcdce.h:RPC_STATUS RPC_ENTRY UuidCreate(UUID*);
>>  >  rpcdce.h:RPC_STATUS RPC_ENTRY UuidCreateNil(UUID*);
>>  >  rpcdce.h:RPC_STATUS RPC_ENTRY UuidCreateSequential(UUID*);
>>  >  rpcdce2.h:RPC_STATUS RPC_ENTRY UuidCreateNil(UUID*);
>>  >  rpcdcep.h:long __stdcall I_UuidCreate(GUID*);
>>  >
>>  >  ...
>>  >
>>  >
>>  >  --
>>  >  Mathieu
>>  >
>>
>>  Is there a difference in between:
>>
>>  __attribute__((__stdcall__))
>>
>>  and
>>
>>   __attribute__((__cdecl__))
>>
>>
>>  Thanks,
>>  --
>>  Mathieu
>>
> 
> Yup that did it:
> 
> char __attribute__((__stdcall__)) UuidCreate(void*);
> 
> int main()
> {
>   UuidCreate(0);
>   return 0;
> }
> 
> So there is a mangling that is not cdecl compatible...
> 
> 
> Any suggestions ?
Yes, write your own try compile that #includes windows.h for the 
declaration of UuidCreate.

-Bill



More information about the CMake mailing list