gpt4 book ai didi

c++ - 从 C0X32.OBJ 引用的未解析的外部 '_main'

转载 作者:行者123 更新时间:2023-11-30 21:16:30 24 4
gpt4 key购买 nike

#include <CkMailMan.h>
#include <CkEmail.h>
#include <stdio>
void ChilkatSample(void)
{
// The mailman object is used for sending and receiving email.
CkMailMan mailman;

// Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
printf("%s\n",mailman.lastErrorText());
return;
}

// Set the SMTP server.
mailman.put_SmtpHost("smtp.chilkatsoft.com");

// Set the SMTP login/password (if required)
mailman.put_SmtpUsername("myUsername");
mailman.put_SmtpPassword("myPassword");

// Create a new email object
CkEmail email;

email.put_Subject("This is a test");
email.put_Body("This is a test");
email.put_From("Chilkat Support <support@chilkatsoft.com>");
email.AddTo("Chilkat Admin","admin@chilkatsoft.com");
// To add more recipients, call AddTo, AddCC, or AddBcc once per recipient.

// Call SendEmail to connect to the SMTP server and send.
// The connection (i.e. session) to the SMTP server remains
// open so that subsequent SendEmail calls may use the
// same connection.
success = mailman.SendEmail(email);
if (success != true) {
printf("%s\n",mailman.lastErrorText());
return;
}

// Some SMTP servers do not actually send the email until
// the connection is closed. In these cases, it is necessary to
// call CloseSmtpConnection for the mail to be sent.
// Most SMTP servers send the email immediately, and it is
// not required to close the connection. We'll close it here
// for the example:
success = mailman.CloseSmtpConnection();
if (success != true) {
printf("Connection to SMTP server not closed cleanly.\n");
}

printf("Mail Sent!\n");
}

我尝试使用 Chilkat 库发送 STMP 邮件。我收到错误:“未解析从 C0X32.OBJ 引用的外部‘_main’。”

最佳答案

您需要一个 main() 函数,它是(托管)实现的 C 入口点。

可能就像添加一样简单:

int main (void) {
ChilkatSample();
return 0;
}

您的代码,否则它可能会更加复杂。

但最重要的是,您的实现启动代码(在 C0X32.OBJ 中)正在尝试查找 main,以便它可以开始正确运行您的程序。

<小时/>

此外,如果您在 stdio header 之后,则应该使用:

#include <stdio.h>

而不是像现在一样放弃扩展。

关于c++ - 从 C0X32.OBJ 引用的未解析的外部 '_main',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24669513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com