lvc / api-sanity-checker

An automatic generator of basic unit tests for a C/C++ library
https://lvc.github.io/api-sanity-checker/
GNU Lesser General Public License v2.1
85 stars 13 forks source link

Problem in running api-sanity-checker on Windows #13

Closed anurag029 closed 11 years ago

anurag029 commented 11 years ago

While running api-sanity-checker 1.98.2 on Windows7 with all the pre-requisites being installed, ERROR: can't compile header(s) is coming while generating the tests. Below is the log file entry: Temporary header file 'C:\Users\ANURAG~1.CHO\AppData\Local\Temp\JXCm5OQczO/dump1.h' with the following content will be compiled to create GCC translation unit dump:

// add includes

include "c:/Path -to-library-headers/zlib-1.2.3-lib/include/zlib.h"

include "c:/Path -to-library-headers/zlib-1.2.3-lib/include/zconf.h"

The GCC parameters: gcc -fdump-translation-unit -fkeep-inline-functions -c -x c++-header -Dthiscall=attribute((thiscall)) -DSORTPP_PASS -Dptr64=" " -Dnullterminated=" " -Duuidof(x)=IID() -Dw64=" " -D_USE_DECLSPECS_FOR_SAL -Dint32=int -Dint64="long long" -Ddeclspec(x)=attribute((x)) -Dinline=inline -D_cdecl=attribute((cdecl)) -Dint16=short -DDECLSPEC_DEPRECATED=" " -D_WIN32 -Dcdecl=attribute((cdecl)) -Dstdcall=attribute((stdcall)) -Dnoop=" " -Dtry= -Dforceinline=inline -D_M_IX86=300 -Dbuiltin_alignof(x)=alignof(x) -D_MSC_EXTENSIONS -Dfastcall=attribute((fastcall)) -D_MSC_VER=1500 -D_stdcall=attribute((stdcall)) -Dexcept(x)= -DSECURITY_WIN32 -D_inline=inline -Dnullnullterminated=" " -D_fastcall=attribute((fastcall)) -Dpragma(x)= -Dint8=char -Dforceinline=inline -D__possiblynotnullterminated=" " -DSHSTDAPI(x)=x -D_thiscall=__attribute((thiscall)) -D_STDCALL_SUPPORTED -D__ptr32=" " -fpermissive -w "C:\Users\ANURAG~1.CHO\AppData\Local\Temp\JXCm5OQczO/dump1.h"

gcc: error: CreateProcess: No such file or directory

Please help.

Thanks!!

aponomarenko commented 11 years ago

Hi,

While running api-sanity-checker on Windows7 with all the pre-requisites being installed, an ERROR of can't find "zip" is coming while generating the test cases.

The api-sanity-checker tool depends on the abi-compliance-checker tool. Please install all its requirements and add them to PATH. I think you've forgot to install Info-ZIP 3.0: http://www.info-zip.org/ Please download and install it (both zip and unzip) from https://sourceforge.net/projects/infozip/files/

List of requirements: http://ispras.linuxbase.org/index.php/ABI_compliance_checker#System_Requirements

gcc: error: CreateProcess: No such file or directory

Please read http://stackoverflow.com/questions/3848357/gcc-createprocess-no-such-file-or-directory

Thanks for reporting issues!

anurag029 commented 11 years ago

Thanks. This problem is solved now.

Started running the tool with libxml2 header files and its dll file. There were 831 test cases generated but were not successfully build. The build errors in build_log file is Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.

NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2' Stop.

and the sample makefile generated is

CC = cl INCLUDES= /I "c:\path-to-header-files" /I ""c:\path-to-header-files"" LIBS = libxml2.lib

all: test.exe

test.exe: test.cpp set LIB="c:\path-to-dll-file\libxmlsrc";$(LIB) $(CC) $(INCLUDES) test.cpp $(LIBS)

clean: del test.exe test.obj

Although I am using dll(dynamic link library) file as a library the Makefile generated adds the extension .lib(static library) to the library. Also it shouldn't be that we use gcc (MinGW) compiler??

Waiting for your reply!!

Thanks!!

anurag029 commented 11 years ago

Thanks. The above problem is solved now.

Started running the tool with libxml2 header files and its dll file. There were 831 test cases generated but were not successfully build. The build errors in build_log file is

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

and the sample makefile generated is

CC       = cl
INCLUDES=  /I "c:\path-to-header-files"  /I ""c:\path-to-header-files""
LIBS     = libxml2.lib
all: test.exe
test.exe: test.cpp
    set LIB="c:\path-to-dll-file\libxmlsrc";$(LIB)
    $(CC) $(INCLUDES) test.cpp $(LIBS)
clean:
    del test.exe test.obj

Although I am using dll(dynamic link library) file as a library the Makefile generated adds the extension .lib(static library) to the library. Also it shouldn't be that we use gcc (MinGW) compiler??

Waiting for your reply!!

Thanks!!

aponomarenko commented 11 years ago

Thanks for the detailed information about the problem.

If you compile the application under Windows then you should link it with *.lib static libraries instead of *.dll dynamic libraries (see "CL Invokes the Linker" article in MSDN). Each *.dll library should have the appropriate *.lib static library in the same directory. So the generated makefile is correct in the case you're testing Windows DLLs.

But you're testing Gcc DLLs, so Windows compiler shouldn't be used in this case and it's definitely the bug in the generator. I'll add the option --target=gcc to build tests by Gcc in the next version of the tool. In the meantime you can use the tool under Linux to avoid such problems.

aponomarenko commented 11 years ago

This problem has been fixed in 1.98.3. Please update.

Use --target=gcc option to generate tests for MinGW DLLs and --target=cl to generate tests for MS DLLs.

shreyas-m791 commented 4 years ago

Can anyone please provide complete instructions to setup and use api-sanity-checker on Windows 10 using MinGW or any other tool?

bsdhw commented 4 years ago

See https://github.com/lvc/api-sanity-checker/issues/33#issuecomment-671523795