@echo off
REM ============================================================
REM  Build the ISQL C example (links isqldll.dll via isqldll.lib).
REM  Run:  examples\build_example.bat
REM  Requires: MSVC x64 build tools (located automatically).
REM ============================================================
setlocal
call "%~dp0findvc.bat" || exit /b 1
call "%VCVARS%" >nul
set ROOT=%~dp0..

cl /nologo /MD /W3 /O2 ^
   /D WIN32 /D _CRT_SECURE_NO_WARNINGS /D _CRT_NONSTDC_NO_WARNINGS ^
   /I"%ROOT%\include\h" ^
   "%ROOT%\examples\isql_example.c" ^
   "%ROOT%\lib\isqldll.lib" ^
   /Fe"%ROOT%\examples\isql_example.exe"

if errorlevel 1 ( echo BUILD FAILED & exit /b 1 )
REM the DLL must sit beside the exe (or on PATH)
copy /y "%ROOT%\bin\isqldll.dll" "%ROOT%\examples\" >nul
echo.
echo Built: %ROOT%\examples\isql_example.exe
echo Run:   "%ROOT%\examples\isql_example.exe" "%ROOT%"
endlocal
