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 6153043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:01:34+00:00 2026-05-23T20:01:34+00:00

I’ve created example C++ project in Visual Studio of dll type. It contains header

  • 0

I’ve created example C++ project in Visual Studio of dll type. It contains header file SqlLtDb.h:

 using namespace std;
    // This class is exported from the SqlLtDb.dll
    class CSqlLtDb {
    public:
        CSqlLtDb(char *fileName);
        ~CSqlLtDb();
        // TODO: add your methods here.
        bool SQLLTDB_API open(char* filename);
        vector<vector<string>> SQLLTDB_API query(char* query);
        bool SQLLTDB_API exec(const char* query);
        void SQLLTDB_API close();
        int SQLLTDB_API getNameOfClass();
    private:
        sqlite3 *database;
    };

extern "C" SQLLTDB_API CSqlLtDb* getInstanceCSblLtDb();
extern SQLLTDB_API int nSqlLtDb;
extern "C" SQLLTDB_API int fnSqlLtDb();

And in SqlLtDb.cpp methods are implemented as follows (I’m showing only two implementation):

...

int SQLLTDB_API CSqlLtDb::getNameOfClass()
{
    return 777;
}

extern "C" SQLLTDB_API CSqlLtDb* getInstanceCSblLtDb()
{
    CSqlLtDb* instance = new CSqlLtDb("");
    return instance;
}

SqlLtDb.def file look like this:

LIBRARY "SqlLtDb"
EXPORTS
getInstanceCSblLtDb
open
query
exec
close
getNameOfClass

SqlLtDb.lib file is generated by LIB command, using above .def file.
This is my SqlLtDb.dll file.

Now I want to include this file to my consoleApplication application.
ConsoleApplication is in VS 2008. I’ve set:

Properties->Configuration Properties->Linker->Input->Additional Dependencies : SqlLtDb.lib;

Properties->Configuration Properties->Linker->General->Additional Library
Directories: E:\PM\SqlLtDb\Release;

Runtime Library is set as it was: Multi-threaded Debug DLL (/MDd) (I didn’t change it).

I copied files: SqlLtDb.dll, SqlLtDb.lib, SqlLtDb.def, sqlite3.dll into Debug folder where consoleApplication.exe is generated. And I added SqlLtDb.h file into folder where consoleApplication's source files are stored.

Function main in consoleApplication look like this:

#include "stdafx.h"
#include "SqlLtDb.h";

int _tmain(int argc, _TCHAR* argv[])
{
    CSqlLtDb* mySqlClass = getInstanceCSblLtDb();  // here is ok, this method is 
                                                   // exported rigth
    mySqlClass->open("");  // here is error whit open method
    return 0;
}

When I compile this code I get error:

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: 
bool __thiscall CSqlLtDb::open(char *)" (__imp_?open@CSqlLtDb@@QAE_NPAD@Z) 
referenced in function _wmain consoleApplication.obj consoleApplication

Method getInstanceCSblLtDb is exported successful, but the problem is with export methods from class. I won’t to export all class, better is export pointer to class.

Thanks

  • 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-23T20:01:36+00:00Added an answer on May 23, 2026 at 8:01 pm

    You need to export the class in the DLL with __declspec(dllexport), and import it in the linking code with __declspec(dllimport). Example:

    class SQLLTDB_API CSqlLtDb {
        ...
    };
    

    You don’t need SQLLTDB_API for each member, only the class – the linker will generate exports for each method for you.

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

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
i want to parse a xhtml file and display in UITableView. what is the

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.