Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6659847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:04:51+00:00 2026-05-26T02:04:51+00:00

I have created an MFC DLL and have exported the functions for example in

  • 0

I have created an MFC DLL and have exported the functions for example in the file SerialPort.h:

class CSerialPortApp : public CWinApp
{
public:
    CSerialPortApp();

    __declspec(dllexport) int SWrite(unsigned char* toSend, int len);
};

and in my MFC application I want to call the function in SerialInterface.h I have included the “SerialPort.h” from the DLL and called:

__declspec(dllimport) int SWrite(unsigned char* toSend, int len);

class SerialInterface
{
public:

};

for example.

I have added the SerialPort.lib file to my linker includes but when I try to compile I get

error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl SWrite(unsigned char*, int)" (__imp_?SWrite@@YAHPAEH@Z)

I am stuck as to the cause of this, I have tried rebuilding everything but nothing seems to help?

Thank you for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:04:52+00:00Added an answer on May 26, 2026 at 2:04 am

    Well I found an alternative that works, I believe I was implementing it incorrectly.

    I added a new class to my DLL that was not a CWinApp class:

    class SerialPort
    {
    public:
        __declspec(dllexport) SerialPort(void);
        __declspec(dllexport) virtual ~SerialPort(void);
    
        __declspec(dllexport) int SWrite(unsigned char* toSend, int len);
    };
    

    then included the header for this in my application and the lib and dll etc.

    I then placed the included header file in the main CDialog header but importantly didn’t need to import any of the functions:

    #include "SerialPort.h"
    
    class CPPUDlg : public CDialog
    {
    public:
        CPPUDlg(CWnd* pParent = NULL); // standard constructor
    
        SerialPort objSerialPort;
    

    and then in my code I simply call

    objSerialPort.SWrite(toSend, len);
    

    I have not used dllimport to import the functions which I assumed I would need to but it now works!

    Hope this helps anyone who may have a similar problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple MFC .dll file and I am able to access
I have tree control object created using CTreeCtrl MFC class. The tree control needs
I have created a C# class file by using a XSD-file as an input.
I have an application which is created using MFC and I have created a
I have created an MFC application from scratch being careful from the start to
I have a MFC wizard based application (CPropertySheet, CPropertyPage) created with vS2008. I am
I have created a C++/CLI mixed DLL which I am using from C# Winforms
I have created a MFC SDI application, and the view is derived from CFormView,
What is the difference between an .OCX file created in MFC or VB and
I have created a user login Dialog Box in MFC, which have two edit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.