CFLite old: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
Guberif (talk | contribs)
No edit summary
m Dave moved page CFLite to CFLite old without leaving a redirect
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page documents how to build CFLite 476.10 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), [[Code/CFLite|click here]].
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), [[Code/CFLite|click here]].
 
'''Huge credit''' for this project goes to '''<email>benjamin.coder.smith@gmail.com|Ben Smith</email>'''.  This guy knows what he's doing and is well worth hiring.  Here is the [https://www.freelancer.com/projects/PHP-C-Programming/Get-CFLite-running-windows.html original project page].


On Windows XP or Windows Vista:<br>
On Windows XP or Windows Vista:<br>


* First, install the built binary by following [[Code/CFLite|The "Easy" Way instructions]].
* Download [http://download.icu-project.org/files/icu4c/4.0/icu4c-4_0-Win32-msvc8.zip ICU4C]  
* Download [http://download.icu-project.org/files/icu4c/4.0/icu4c-4_0-Win32-msvc8.zip ICU4C]  
* Download [http://www.opensource.apple.com/darwinsource/tarballs/apsl/CF-476.13.tar.gz CFLite 476.13].
* Download [http://www.opensource.apple.com/darwinsource/tarballs/apsl/CF-476.17.tar.gz CFLite 476.17].
* Get FreeBSD's [http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/sys/libkern/flsl.c?rev=1.4;content-type=text%2Fplain flsl.c] source file
* Download <googa>http://kjams.com/cflite/downloads/include.zip|include.zip|/downloads/CFLiteIncludes</googa> (contains /usr/include/*, which includes AvailabilityMacros, AssertMacros and TargetConditionals from 10.5)
* Download [http://kjams.com/cflite/downloads/include.zip include.zip] (contains /usr/include/*, which includes AvailabilityMacros, AssertMacros and TargetConditionals from 10.5)
* Download [http://kjams.com/cflite/downloads/patch_and_flsl.zip patch_and_flsl.zip] (contains the patcher and the flsl.c file)
* You will need the contents of include/mach/ and include/i386/, and the files include/malloc/malloc.h, include/sys/cdefs.h, include/AssertMacros.h, include/AvailabilityMacros.h, and include/TargetConditionals.h from include.zip
* Install [[CFLite/Cygwin|Cygwin]].  Follow the link for detailed instructions.
 
 
* Install [[CFLite/Cygwin|Cygwin]] - select (click the text labelled Skip, it will change to a package version) these packages during the install:
** Devel/gcc-core
** Devel/gcc-objc
** Devel/make
** Devel/patchutils
** If you want to debug the dll, also install Devel/gdb.
 
 
* Arrange the source files.  This layout is the format that the patch understands.
* Arrange the source files.  This layout is the format that the patch understands.
** Extract CF-Lite to a place of your choosing.  You'll need to get to the directory easily from cygwin, so make it somewhere simple.
** 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".
** Open the directory where you extracted CF-Lite.
** Rename this folder to be "CFLite"
** The patch does not yet cover the following source files and their contained features.  The build process for CF-Lite is... unique, you'll want to move or remove these files.  A suitable Makefile would be superior.
** Open the "CFLite" folder.
*** CFConcreteStreams.c
** 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 [http://kjams.com/cflite/downloads/hideUnsupported.sh.zip a shell script] for this, i haven't tried it but feel free.
*** CFMachPort.c
CFConcreteStreams.c
*** CFMessagePort.c
CFMachPort.c
*** CFPlugIn_Instance.c
CFMessagePort.c
*** CFRunLoop.c
CFPlugIn_Instance.c
*** CFRunLoopPriv.h
CFRunLoop.c
*** CFSocket.c
CFRunLoopPriv.h
*** CFSocketStream.c
CFSocket.c
*** CFStream.c
CFSocketStream.c
*** CFStringDefaultEncoding.h
CFStream.c
*** CFUserNotification.c
CFStringDefaultEncoding.h
*** CFVersion.c
CFUserNotification.c
*** CFWindowsMessageQueue.c
CFWindowsMessageQueue.c
*** CFWindowsMessageQueue.h
CFWindowsMessageQueue.h
** Create a folder in your windows directory named CoreFoundation.  Under it, make a new folder named CoreFoundation.resources.  Under that one, create one called CharacterSets. You should now have the path \WINDOWS\CoreFoundation\CoreFoundation.resources\CharacterSets.
** You may also delete these files, as they are already installed (from step 1):
** Move the files CFCharacterSetBitmaps.bitmap, CFUniCharPropertyDatabase.data, CFUnicodeData-B.mapping, CFUnicodeData-L.mapping into the new CharacterSets folder.
  CFCharacterSetBitmaps.bitmap
** Copy flsl.c into your CFLite folder.
CFUniCharPropertyDatabase.data
** Create a folder named include, in the CF-Lite folder.
CFUnicodeData-B.mapping
** Open the include folder that you just made.
CFUnicodeData-L.mapping
** Create a folder named malloc.  Copy include.zip's include/malloc/malloc.h into this folder.
** Unzip '''patch_and_flsl.zip''' and place it's 2 files into your CFLite folder. This will place your patcher and the flsl.c file both in that directory.
** Create a folder named sys.  Copy include.zip's include/sys/cdefs.h into it.
** Unzip '''Include.zip''' into your CFLite folder (it will be in it's own folder)
** Copy include.zip's include/AvailabilityMacros.h, include/AssertMacros.h, and include/TargetConditionals.h files and the include/mach and include/i386 folders into your include folder.
** Unzip the '''ICU4C''' package into the Include folder that was just created.  It should extract into a folder called '''icu'''.
** Extract the ICU4C package in the include folder.  It should extract into an icu folder.
 
 
Your include folder should look like this when you're finished.
INCLUDE_SCREENSHOT_HERE


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)<br>
http://kjams.com/cflite/screenshots/cfbuild_include_folder_screenshot.png


* Navigate to the folder where you extracted CF-Lite on your Cygwin command prompt.
* at your Cygwin command prompt, navigate IN to the CFLite folder (so you're seeing it's contents)
** 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.
** 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
make
** 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)


* Apply the patch.  The patch is a patch against CFLite-476.13.  Where to host patch?
==Using CFLite in your own programs==
** Use the command 'patch -p1 < cf_windows.patch'
* What development Environment are you using?
 
** GCC
 
* Run make.  Just type make and press enter.
** There are a lot of warnings.
** If you need to capture stderr during the build process, use make 2>error_log.txt instead.
** Your .dll and .lib files will be in your current directory.  The directory include/CoreFoundation/ will contain the Core Foundation headers that you use for other programs.
 
 
* Using CF-Lite in your own programs:
** If you're using GCC
*** You will need to define the preprocessor directive __WIN32__ in your build.
*** You will need to define the preprocessor directive __WIN32__ in your build.
*** Works just like using a DLL in other GCC apps.
*** 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.
*** 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
** Visual Studio 2005
*** You will need to define the preprocessor directive __WIN32__ in your build.
*** You followed the original instructions for "the easy way" right?
*** In release target builds, you need to disable Visual Studio's library loading trimming.  To do this, open your project properties, expand Configuration Properties, expand Linker, select Optimizations, then set the field labelled references to ''''Keep Unreferenced Data (/OPT:NOREF)''''.  If you don't do this, you can have crashes at fairly innocent seeming functions because Visual Studio didn't load the object code for that particular module.
** CodeWarrior
*** CoreFoundation relies on the stdint.h and stdbool.h files, you'll need [http://msinttypes.googlecode.com/svn/trunk/stdint.h stdint.h] and [http://www.koders.com/c/fidDF4818DD265741F8A74455FC281F0C1CBA35EB47.aspx stdbool.h] They don't come with the compiler but are part of the C99 standard. You'll need to put them on your include path.  I placed mine in my compiler's include folder because they help support C99 and don't interfere with my compiler workings.
*** 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 [[CFLite/CFTest|CFTest]] source files.  This is the test harness sample project.
* Download the <googa>http://kjams.com/cflite/downloads/CFTest.zip|CFTest|/downloads/CFTest</googa> source files.  This is the test harness sample project and includes some extremely high win factor utilities
** You can ignore the XCode project
** open it up and go to the "win_vs" folder for Visual Studio project, or "win_cw" for the CodeWarrior project
** create a new project in your windows dev environment and add the two .cpp files.<br>
** the "console.txt" is the example output that it '''should''' look like in your console or log file
** the "console.txt" is the example output that it '''should''' look like in your console
** you may need to tweak the relative path for "test.xml" to load properly. 
 
Please document any necessary changes to the source code.

Latest revision as of 17:27, 19 July 2017

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 <email>benjamin.coder.smith@gmail.com|Ben Smith</email>. 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 include.zip (contains /usr/include/*, which includes AvailabilityMacros, AssertMacros and TargetConditionals from 10.5)
  • Download patch_and_flsl.zip (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.
CFConcreteStreams.c
CFMachPort.c
CFMessagePort.c
CFPlugIn_Instance.c
CFRunLoop.c
CFRunLoopPriv.h
CFSocket.c
CFSocketStream.c
CFStream.c
CFStringDefaultEncoding.h
CFUserNotification.c
CFWindowsMessageQueue.c
CFWindowsMessageQueue.h
    • You may also delete these files, as they are already installed (from step 1):
CFCharacterSetBitmaps.bitmap
CFUniCharPropertyDatabase.data
CFUnicodeData-B.mapping
CFUnicodeData-L.mapping
    • Unzip patch_and_flsl.zip 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 Include.zip 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)
cfbuild_include_folder_screenshot.png

  • 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
make
    • 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