From kJams Wiki
Jump to: navigation, search

This page documents how to build CFLite 476.17 such that you can then link to it in your Windows projects, and then blissfully use CFStrings, CFDictionaries, and all the other CFGoodness that CFLite will bring you. For a "quick and dirty" way to just start *using* CFLite on windows (without having to compile it), click here.

Huge credit for this project goes to . This guy knows what he's doing and is well worth hiring. Here is the original project page.

On Windows XP or Windows Vista:

  • First, install the built binary by following The "Easy" Way instructions.
  • Download ICU4C
  • Download CFLite 476.17.
  • Download (contains /usr/include/*, which includes AvailabilityMacros, AssertMacros and TargetConditionals from 10.5)
  • Download (contains the patcher and the flsl.c file)
  • Install Cygwin. Follow the link for detailed instructions.
  • Arrange the source files. This layout is the format that the patch understands.
    • Extract CFLite to a place of your choosing. You'll need to get to the directory easily from cygwin, so make it somewhere simple. It will unzip into a folder called "CF-476.13".
    • Rename this folder to be "CFLite"
    • Open the "CFLite" folder.
    • Delete the following files: The patch does not yet cover these source files and their contained features. The build process for CFLite is... unique, you'll want to move or remove these files. (A suitable Makefile would be superior) Update: a nice user wrote a shell script for this, i haven't tried it but feel free.
    • You may also delete these files, as they are already installed (from step 1):
    • Unzip and place it's 2 files into your CFLite folder. This will place your patcher and the flsl.c file both in that directory.
    • Unzip into your CFLite folder (it will be in it's own folder)
    • Unzip the ICU4C package into the Include folder that was just created. It should extract into a folder called icu.

Your include folder should look like this when you're finished. (Ignore the fact that the path does not contain the word "CF-476.13", yours should)

  • at your Cygwin command prompt, navigate IN to the CFLite folder (so you're seeing it's contents)
    • Note: Cygwin will execute regular dos commands like dir, copy, del, or you can use their unix equivalents ls, cp, rm. Change directories with the cd command.
    • Note: Cygwin maps disk drive letters to a mount point in the folder /cygdrive/. For example; /cygdrive/c/ is equivalent to C:\, and /cygdrive/m/ would be M:\ at a DOS prompt or under My Computer.
  • Apply the patch. The patch is against CFLite '476.17, patching will fail with any other version.
    • Use this patch command from inside the CFLite directory. Note that is a "Number One" after the -p, it is not a "Letter Ell".
patch -p1 < cf_windows.patch
  • Now make the binary
    • you should get NO warnings or errors.
    • Your built .dll and .lib files will be installed into your \WINDOWS\CoreFoundation\ directory after being built.
    • Your modified CF headers will be NOT copied into \WINDOWS\CoreFoundation\CoreFoundation\ unless you modify the "BuildCFLite" text file, and un-comment the relevant section (toward the end)

Using CFLite in your own programs

  • What development Environment are you using?
    • GCC
      • You will need to define the preprocessor directive __WIN32__ in your build.
      • Works just like using a DLL in other GCC apps.
      • Make sure you use the -mno-cygwin flag to prevent gcc from linking with the cygwin dll and C runtime. Link with -lmsvcrt instead.
    • Visual Studio 2005
      • You followed the original instructions for "the easy way" right?
    • CodeWarrior
      • add the dll to your project
      • add the 2 include paths
      • you can't use the functions "CFAbsoluteTimeGetGregorianDate" and "CFAbsoluteTimeGetDifferenceAsGregorianUnits" because they return structs. Instead, use "CFAbsoluteTimeGetGregorianDate_MW" and "CFAbsoluteTimeGetDifferenceAsGregorianUnits_MW" respectively. See CFTest (below) for an example.
  • Download the CFTest source files. This is the test harness sample project and includes some extremely high win factor utilities
    • open it up and go to the "win_vs" folder for Visual Studio project, or "win_cw" for the CodeWarrior project
    • the "console.txt" is the example output that it should look like in your console or log file