[CMake] CHECK_FUNCTION_EXISTS(UuidCreate HAVE_UUIDCREATE)
Mathieu Malaterre
mathieu.malaterre at gmail.com
Mon May 5 14:53:37 EDT 2008
On Mon, May 5, 2008 at 8:49 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
>
> Mathieu Malaterre wrote:
>
> > Ok. I do not understand how to use cl, I switch to using gcc instead
> > (cygwin). Here it is again:
> >
> >
> > /usr/local/bin/gcc.exe -DCHECK_FUNCTION_EXISTS=UuidCreate -o
> > CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.o -c
> > /usr/share/cmake-2.4.8/Modules/CheckFunctionExists.c
> > Linking C executable cmTryCompileExec.exe
> > /usr/bin/cmake.exe -P
> CMakeFiles/cmTryCompileExec.dir/cmake_clean_target.cmake
> > /usr/local/bin/gcc.exe -DCHECK_FUNCTION_EXISTS=UuidCreate
> > "CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.o" -o
> > cmTryCompileExec.exe
> > -Wl,--major-image-version,0,--minor-image-version,0 -lrpcrt4
> >
> CMakeFiles/cmTryCompileExec.dir/CheckFunctionExists.o:CheckFunctionExists.c:(.text+0x1a):
> > undefined reference to `_UuidCreate'
> > collect2: ld returned 1 exit status
> > make[1]: Leaving directory
> > `/home/mmalaterre/Projects/gdcm/debug-gcc422/CMakeFiles/CMakeTmp'
> > make[1]: *** [cmTryCompileExec.exe] Error 1
> > make: *** [cmTryCompileExec/fast] Error 2
> >
> >
> > where is the '_' coming from ? Is this something standard to gcc ?
> >
> >
>
> Standard for C compilers to add _ infront of any symbol.
>
> 1. Use --debug-trycompile.
> 2. Get the source code out created in --debug-trycompile run
> 3. try to compiple the source code by hand cl CheckFunctionExists.c
> rpcrt4.lib or gcc CheckFunctionExists.c -lrpcrt4.
> 4. look at the code in CheckFunctionExists.c
>
> If I had to guess, I would say CheckFunctionExists.c forward declares a C
> function, and that UuidCreate is somehow a macro in windows.h
-> 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*.
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
...
--
Mathieu
More information about the CMake
mailing list