Chilkat PureBasic Module

for Windows, Linux, and MacOS.

Download

v10.0.0 28-Sep-2024sha256: 55f1b5b78baa70fbc23b35a5f75fde6ca32dd0a71525a3c517ce2f67b9c670b4
Chilkat PureBasic Module

Getting Started Instructions

  1. Download and unzip to any directory.
  2. The native Windows, Linux, and MacOS implementation are contained in the DLL, .so, and dylib files:
    • chilkatPb.dll (The Chilkat DLL for 64-bit Windows)
    • chilkatPb32.dll (The Chilkat DLL for 32-bit Windows)
    • libchilkatPb.dylib (The Chilkat dylib for MacOSX)
    • libchilkatPbM1.dylib (The Chilkat dylib for MacOSX M1 arm64)
    • libchilkatPb32.so (The Chilkat shared library for 32-bit Linux)
    • libchilkatPb.so (The Chilkat shared library for 64-bit Linux)
    • libchilkatPbArm32.so (The Chilkat shared library for 32-bit ARM Linux)
    • libchilkatPbArm64.so (The Chilkat shared library for 64-bit ARM Linux)
  3. The Chilkat PureBasic modules are the .pb files beginning with "Ck". For example:
    • CkFtp2.pb
    • CkEmail.pb
    • CkImap.pb
    • CkSsh.pb
    • ...
    • Important: Make sure the .pb files and .so/.dll/.dylib are from the same Chilkat version. Mixing different older/newer .pb sources with a different version shared lib will result in a crash.
  4. Example Code: Chilkat PureBasic Module Example Code
  5. Reference Documentation: Chilkat PureBasic Module Reference Documentation
  6. Important: If your code using Chilkat crashes on your first try, it is because the native libary (.so, .dll, or .dylib) could not be found by the operating system. See this Chilkat Forum post for information: PureBasic OpenLibrary Failed
  7. Note: If your PureBasic application is a shared DLL, then make sure to call each Chilkat module's ckInitGlobal before using it. For example, for CkZip call CkZip::ckInitGlobal(). The call(s) to ckInitGlobal can be placed within the AttachProcess method of the DLL.

Programming Tips

Process Windows Events in Loops that Take a Long Time to Run

If your code has a loop that takes a long time to run, then make sure to process Windows events by calling WindowEvent. See PureBasic WindowEvent, and PureBasic Windows Message Handling. Otherwise Windows will complain that your application has stopped responding.

My PureBasic Application Crashes on Linux when Running as an Executable, but not when Debugging in the IDE

The Chilkat PureBasic download contains one .pb file for each Chilkat class. The following code snippet exists in each .pb file.

  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "chilkatPb32.dll")
      CompilerElse
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "chilkatPb.dll")
      CompilerEndIf
    CompilerCase #PB_OS_MacOS
      CompilerIf #PB_Compiler_Processor = #PB_Processor_arm64
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPbM1.dylib")
      CompilerElse
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPb.dylib")
      CompilerEndIf
    CompilerCase #PB_OS_Linux
      ; Note: The full path of the .so shared library will be required when running from a compiled executable on Linux.
      ; See https://www.purebasic.fr/english/viewtopic.php?t=79882
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPb32.so")
      CompilerElseIf #PB_Compiler_Processor = #PB_Processor_arm32
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPbArm32.so")
      CompilerElseIf #PB_Compiler_Processor = #PB_Processor_arm64
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPbArm64.so")
      CompilerElse
        CkGlobalLibId.i = OpenLibrary(#PB_Any, "libchilkatPb.so")
      CompilerEndIf
  CompilerEndSelect

When running your application from a compiled executable on Linux, the full path of the shared library (.so) must be specified. For example, "/home/robert/chilkatPbLib/libchilkatPb.so". Unfortunately, you'll need to manually update the .pb files based on the location of the shared libs. Most editors provide "Find and Replace in Files" functionality that should allow for a single find/replace for all .pb files. For example, replace "libchilkatPb" with "/home/robert/chilkatPbLib/libchilkatPb".