VC++ Link problem: fatal error C1047, “Chilkat*.lib’ was created with an older compiler than other objects; rebuild old objects and libraries”

Regarding the following VC++ link problem:

“fatal error C1047: The object or library file 'c:\Chilkat\libs\x64\ChilkatRel_x64.lib' 
was created with an older compiler than other objects; rebuild old objects and libraries”

This can be resolved by building without the /LTCG flag turned on. Unfortunately, it is not possible to use the /LTCG flag if you are using the Chilkat libraries. Compiling and linking your C++ application without using the /LTCG flag should resolve the problem.

Using Chilkat in Managed C++

The Chilkat VC++ static libraries are for unmanaged C++ applications. A Managed C++ application (using Microsoft’s Managed Extensions for C++) runs within the .NET Framework and therefore must use the Chilkat .NET assembly.

The Chilkat C++ online reference documentation and online examples are for unmanaged C++ applications. For Managed C++, the best choice is to read the C# online documentation and C# online examples (at Managed C++ syntax is closer to C# syntax than unmanaged C++ syntax.

To see the differences in syntax, here are some sample code fragments in unmanaged C++, Managed C++, and C#.

Unmanaged C++

#include <CkFtp2.h>

void FtpExample(void)
    CkFtp2 ftp;

    //  Any string unlocks the component for the 1st 30-days.
    bool success = ftp.UnlockComponent("Anything for 30-day trial");


    success = ftp.Connect();


Managed C++

    Chilkat::Ftp2 ftp;
    ftp.UnlockComponent("30-day trial");

    ftp.Hostname = "";
    ftp.Username = "myLogin";
    ftp.Password = "myPassword";

    bool success = ftp.Connect();



Chilkat.Ftp2 ftp = new Chilkat.Ftp2();

bool success = ftp.UnlockComponent("Anything for 30-day trial");

ftp.Hostname = "";
ftp.Username = "myLogin";
ftp.Password = "myPassword";

success = ftp.Connect();


Non-English String Literals in C++ Source Code

When a C++ compiler compiles a C++ source file, it must process the bytes according to a character encoding and that is typically ANSI.  ANSI is not a character encoding, it is simply a keyword that says “Use the default multi-byte character encoding for this computer based on its current locale.”   Therefore, if your program is originally written in Poland and contains string literals (i.e. character string constants in double-quotes) with Polish characters, the same source when compiled on a typical computer in France will not produce the same results.  The bytes for the Polish characters will instead be interpreted as Latin1 characters and the string will be different.  This example demonstrates a technique you may use to embed string literals using quoted-printable so that the C++ source may be compiled on any computer without character encoding issues caused by the locale.   Chilkat provides a free tool to quoted-printable encode a string (which may contain characters in any language):

Quoted-Printable Encoding Tool Download

Here is a screenshot:

Quoted-Printable Encoder

The quoted-printable encoder is a very simple C# program that uses the Chilkat.CkString class.   Here is the complete source code:

        private void button1_Click(object sender, EventArgs e)
            Chilkat.CkString str = new Chilkat.CkString();
            textBox2.Text = str.getString();

Using Quoted-Printable String Literals in C++

Use the tool to convert your string to quoted-printable using the utf-8 character encoding.  (utf-8 is the multi-byte encoding for Unicode, so it is able to mix characters of any language in a single NULL-terminated string.  A “multibyte” encoding is a character encoding such that each character is represented by one or more bytes, and there are no NULL bytes.)

Use the quoted-printable encoded string in your C++ source code like this:
(This example constructs an IMAP mailbox name using Vietnamese characters)

    CkImap imap;
    bool success;

    CkString str;
    str.append("C=C3=B4ng c=E1=BB=99ng");

    success = imap.CreateMailbox(str.getUtf8());
    if (success != true) {

Utf8 C++ property allows for utf-8 or ANSI “const char *”

All Chilkat C++ classes have a Utf8 property. For example:

class CkEmail : public CkObject

	virtual ~CkEmail();

	bool get_Utf8(void) const;
	void put_Utf8(bool b);

	const char *addFileAttachment(const char *fileName);

The Utf8 property controls how the bytes pointed by “const char *” arguments are interpreted. By default, “const char *” strings are interpreted as ANSI bytes. If the Utf8 property is set to true by calling put_Utf8(true), then “const char *” inputs are interpreted as utf-8. This allows any application to pass either ANSI or utf-8 strings to any Chilkat method.

The Utf8 property also controls whether utf-8 or ANSI strings are returned by methods that return a “const char *”.