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

  • SEARCH
  • Home
  • 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 8338001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:27:44+00:00 2026-06-09T04:27:44+00:00

I am trying to import a dll to a C# console application just to

  • 0

I am trying to import a dll to a C# console application just to see if I can get a dll to work as a want, when trying this and exporting functions with C-code everything works fine and the functions can be imported in my C# application.

The problem starts when I try to add some kind of linkage to some QT methods in my unmanaged dll. I’m using DllImport to import the functions from the dll.

[DllImport("cDLL.dll", EntryPoint = "_Add@16")]
static extern double Add(double a, double b);

1 – This is how the unmanaged dll (don’t look at the functionality of the code, this is just for testing purposes) looks like when it works fine.

main.cpp working

#include <stdexcept>
#include "Windows.h"

using namespace std;

extern "C" __declspec(dllexport) double __stdcall Add(double a, double b)
{
    return a + b;
}
extern "C" __declspec(dllexport) const char* getText()
{
    return "hello world";//returnBufferString.c_str();
}
BOOL __stdcall DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved) {
    return TRUE;
}

2 – When I try to add a help function with some QT code, just an ordinary QString the DllImport starts throwing dllNotFoundException.dumpbin.exe shows all the exported functions as well after including the qt code…

main.cpp dllNotFoundException

#include <QString>
using namespace std;
class testa
{
public:
    static char* test()
    {
        QString a = "hejsan";
        return qString2Char(a);
    }
    static char* qString2Char(QString a)
    {
        return a.toUtf8().data();
    }
};

This is called from the getText() function like this:

string returnBufferString;
extern "C" __declspec(dllexport) const char* getText()
{
    returnBufferString = testa::test();
    return returnBufferString.c_str();
}

When I try to access the dll from DllImport I get dllNotFoundException in the 2:nd part. How do I solve this? have I missed any dependencies or anything. My dll is build using msvc2010 compiler and the .pro file looks like this:

cDLL.pro

TEMPLATE = lib
 CONFIG  += dll

QT += core

 # Input
 SOURCES += main.cpp

I’m stuck…

  • 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-06-09T04:27:46+00:00Added an answer on June 9, 2026 at 4:27 am

    It doesn’t tell you exactly what DLL it cannot find. Which is almost surely not your DLL, it is one of the DLLs that QT requires. You’d have to copy them to the EXE folder as well. If you have no idea and can’t find it in the Nokia documentation then you can find out with SysInternals’ ProcMon utility.

    However, in this scenario you surely want to link QT into your DLL since the odds that those DLLs can be shared are small. Use this SO question for guidance in setting up your QT project.

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

Sidebar

Related Questions

I'm trying to import a dll, namely msado15.dll. I can do this fine with
I’m having some difficulties while trying to consume an unmanaged-code dll from my application
I am trying to import a function from an unmanaged code c++ dll into
I am trying to import a dll written in C++, in my C# application.
I trying to load SFmpq.dll via this code static { Native.setProtected(true); System.setProperty(jna.library.path, new File(lib).getAbsolutePath());
I'm trying to write a DLL that I can import in Python (2.7), and
I am trying this import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream;
I'm trying to import our SVN repository into Git. When I run either this
So, I'm trying to get gtksourceview python bindings work under windows (I'm developing a
I'm trying to import a IntelliJ java web application project (Maven Project) from a

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.