未定义的引用(QuickMail)
我正在寻找如何安装快速邮件。
我将 quickmail.h
放在这里:C:\Program Files\CodeBlocks\MinGW\include
、.a
和 .la< /code> 此处:
C:\Program Files\CodeBlocks\MinGW\lib
。
我通过将这些 .a
文件添加到链接器设置中来链接它们。我也确实包含了这样的库:#include
,但功能无法识别。
我应该怎么办 ?
bin文件夹中的4个文件位于项目文件夹中,我从这里下载了文件: quickmail - Sourceforge。
编辑:我得到\main.c|9|对'__imp_quickmail_initialize'的未定义引用| \main.c|10|对“__imp_quickmail_create”的未定义引用| \main.c|11|对 '__imp_quickmail_set_body' 的未定义引用
,我将 C:\Program Files\CodeBlocks\MinGW\include
放入搜索目录中。
这是代码:
#include <stdio.h>
#include <stdlib.h>
#include <quickmail.h>
int main()
{
const char* error;
quickmail_initialize();
quickmail mailobj = quickmail_create("[email protected]", "libquickmail test e-mail");
quickmail_set_body(mailobj, "This is a test e-mail.\nThis mail was sent using libquickmail.");
quickmail_add_attachment_file(mailobj, "words.txt", NULL);
if ((error = quickmail_send(mailobj, "smtp.gmail.com", 587, "[email protected]", "MAGA2020")) != NULL)
fprintf(stderr, "Error sending e-mail: %s\n", error);
quickmail_destroy(mailobj);
return 0;
}
抱歉,该网站给了我错误的版本。
I am looking for how to install quickmail.
I put quickmail.h
here: C:\Program Files\CodeBlocks\MinGW\include
, the .a
and .la
here: C:\Program Files\CodeBlocks\MinGW\lib
.
I linked these .a
files by adding them in the linker settings. I also did include the library like this: #include <quickmail.h>
, but the functions are not recognized.
What should I do ?
The 4 files in the bin folder are in the project folder and I downloaded files from here : quickmail - Sourceforge.
EDIT : I get \main.c|9|undefined reference to '__imp_quickmail_initialize'| \main.c|10|undefined reference to '__imp_quickmail_create'| \main.c|11|undefined reference to '__imp_quickmail_set_body'
and I put C:\Program Files\CodeBlocks\MinGW\include
in search directories.
This is the code :
#include <stdio.h>
#include <stdlib.h>
#include <quickmail.h>
int main()
{
const char* error;
quickmail_initialize();
quickmail mailobj = quickmail_create("[email protected]", "libquickmail test e-mail");
quickmail_set_body(mailobj, "This is a test e-mail.\nThis mail was sent using libquickmail.");
quickmail_add_attachment_file(mailobj, "words.txt", NULL);
if ((error = quickmail_send(mailobj, "smtp.gmail.com", 587, "[email protected]", "MAGA2020")) != NULL)
fprintf(stderr, "Error sending e-mail: %s\n", error);
quickmail_destroy(mailobj);
return 0;
}
Sorry, the site gave me the wrong version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用库,您需要在代码中包含标头(在本例中为
#include
),并在需要时告诉编译器在哪里可以找到该文件(该文件的完整路径)lib
文件夹),带有-I
编译器标志。接下来,您需要告诉链接器与库链接(在本例中是
-lquickmail
或-lquickmaillight
),以及如果需要的话在哪里可以找到该文件(指向该库的完整路径)lib
文件夹),带有-L
链接器标志。您的错误是链接器错误,因此第二步似乎没有正确完成。
在 Code::Blocks 中,它看起来像这样(尽管与屏幕截图不同,您应该将其设置在顶层,而不仅仅是用于调试构建):



To use a library you need to include the header in the code (in this case
#include <quickmail.h>
) and if needed tell the compiler where to find this file (the full path to thelib
folder) with the-I
compiler flag.Next you need to tell the linker to link with the library (in this case
-lquickmail
or-lquickmaillight
) and if needed where to find this file (the full path to thelib
folder) with the-L
linker flag.Your errors are linker errors, so it seems the second step wasn't properly done.
In Code::Blocks it looks like this (though unlike the screenshots you should set it at the top-level instead of just for Debug builds):


