bluetiger9 / SmtpClient-for-Qt

An SMTP Client writen in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.
https://github.com/bluetiger9/SmtpClient-for-Qt/wiki
GNU Lesser General Public License v2.1
449 stars 226 forks source link

Using SmtpMime as a static library #136

Closed perdrix52 closed 1 year ago

perdrix52 commented 1 year ago

I built the project as a static library which went well, but linking want totally all over the place

In the end I changed smtpmime_global.h

if (0)

ifdef SMTP_MIME_LIBRARY

define SMTP_MIME_EXPORT Q_DECL_EXPORT

else

define SMTP_MIME_EXPORT Q_DECL_IMPORT

endif

endif

define SMTP_MIME_EXPORT

Is that the recommended way to handle this?

Thank you David

StEvUgnIn commented 1 year ago

What is the question?

perdrix52 commented 1 year ago

I asked if the changes I made to the header was the recommended way to fix the problem I reported here.

StEvUgnIn commented 1 year ago

No, it is not.

The snippet disables the import / export modifier used in MS Windows. Of course, it can work under different environment but it won't in a MS pure environment, especially if the compiler is Visual C++ for instance.

perdrix52 commented 1 year ago

OK If that's not the recommended way to get it to build as a static library, and be able to link with an application, please advise what change I should make. It absolutely does work in a VS C++ environment as I'm using the static library right now

perdrix52 commented 1 year ago

To clarify if I build it as a static library SMTP_MIME_LIBRARY should resolve to nothing (as per the last line of my original post). It can't be either declspec(dllexport) or declspec(dllimport) as both those prevent the link from working.

bluetiger9 commented 1 year ago

@perdrix52 , the project is not really meant to be compiled as a static library. But you if the method you described works, you are free to use it.