Linking your macOS C++ Application with the Chilkat Library
Your application will link with libchilkat.a, and also a few system libraries and macOS frameworks.
- Chilkat Univeral Library -
- libchilkat.a
- System Libraries -
- "-lpthread" → POSIX threads
- "-lresolv" → DNS resolver library
- "-ldl" → Dynamic linking library
- macOS Frameworks -
- "-framework CoreFoundation"
- "-framework Security"
Run the following command shows how to link, assuming you put libchilkat.a in the same directory as your source file.
g++ main.cpp -L. -lchilkat -lmylib -lpthread -lresolv -ldl -framework CoreFoundation -framework Security -o myapp
Explanation:
- "g++ main.cpp" → Compiles "main.cpp".
- "-L." → Look for libraries in the current directory.
- "-lchilkat" → Link against "libchilkat.a" (omit "lib" prefix and ".a" extension).
- "-lpthread" → Link with POSIX threads.
- "-lresolv" → Link with the resolver library.
- "-ldl" → Link with the dynamic linking library.
- "-framework CoreFoundation" → Link with Apple's CoreFoundation framework.
- "-framework Security" → Link with Apple's Security framework.
- "-o myapp" → Output the executable as "myapp".