enr4ged
enr4ged

Reputation: 141

Having trouble building and using a DLL in C++

Here is the error I am receiving when running the project that I am using the DLL in:

No Entry Point error

The odd thing is that this was working at one point. I took a break from this project for a while and now it is not working. Not much has changed besides changing a couple of the parameters.

My setup includes a project in which I build the DLL. This project is then used in a solution with another project that I use to test it. I followed this example: https://msdn.microsoft.com/en-us/library/ms235636.aspx in which I also followed the first time and had it working, now it has stopped.

After realizing it seems to be only one of the functions that is causing the problem I have removed all of the extra code, tried renaming the function, removing everything in it and it is STILL not working.

You can see the function definitions and signatures to see how I am attempting to get this to work below

I have also tried using the "SCOREINTERFACECPP" macro I created on the function instead of the class and I get the same error.

In the project I am testing it in I added the DLL project as a reference and a dependent project, then imported the header file. The other functions I have in the dll (that I have removed from this code for simplicity sake) seem to be working.

Header:

#ifdef SCOREINTERFACECPP_EXPORTS
#define SCOREINTERFACECPP __declspec(dllexport) 
#else
#define SCOREINTERFACECPP __declspec(dllimport) 
#endif

#include <time.h>
#include <queue>

namespace ScoreInterfaceCPP
{
    class SCOREINTERFACECPP ScoreInterface
    {

    public:

        ScoreInterface();
        ~ScoreInterface();

        static void SubmitLogin(const std::string &displayName, const std::string &password);

        static void Shutdown();

        static SIEvent* GetNextEvent();
        static void ClearEvents();
        static int GetEventCount();

    private:

        static std::queue< SIEvent* > mSIEvents;
        static bool mGameIsAuthorized;
        static std::string mGameName;

        static std::string hexedKey;
        static std::wstring mAddress;

        static void SubmitEventString(std::string eventString);

        static int SubmitWithNewThread(void* data);

        static void PostMessage(std::string data, std::string iv);
    };
}

Source:

#include <sstream>

#include <SDL/SDL_thread.h>
#include <boost/tokenizer.hpp>

#include "ScoreInterfaceCPP.h"
#include "Network.h"

using namespace ScoreInterfaceCPP;

/*
    ScoreInterfaceCPP.h
    Handles the sending and receiving of events.
*/

ScoreInterface::ScoreInterface()
{
}

ScoreInterface::~ScoreInterface()
{
}

void ScoreInterface::SubmitLogin(const std::string &displayName, const std::string &password)
{       
}

void ScoreInterface::SubmitEventString(std::string eventString)
{       
}

int ScoreInterface::SubmitWithNewThread(void* data)
{   
    return 0;
}

SIEvent* ScoreInterface::GetNextEvent()
{   
    return NULL;
}

int ScoreInterface::GetEventCount()
{
    return 0;
}

void ScoreInterface::ClearEvents()
{
}

void ScoreInterface::Shutdown()
{
}

Test file:

#include "ScoreInterfaceCPP.h"

using namespace ScoreInterfaceCPP;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    ScoreInterface si = ScoreInterface();

    si.SubmitLogin("noplayer", "nopassword");

    return 0;
}

Upvotes: 0

Views: 75

Answers (1)

PaulMcKenzie
PaulMcKenzie

Reputation: 35440

In my experience, usually problems of this type come with two things you should check (assuming the DLL was built successfully):

  1. Check that the DLL being loaded at runtime is the correct version.
  2. Ensure that the function in question is actually exported.

For the first issue, you can use a utility such as Process Explorer and look at the DLL handles that are loaded for your running exectuable. If you are using Visual C++, you can also look at the Output Window listing of the DLL's that are loaded, and ensure that the version you're using is being loaded.

Many times during development, you may have several (either by accident or by design) versions of your DLL lying in a directory that is accessible by Windows (see DLL Search Order), and thus an old or different version of your DLL is being loaded when you run your application.

For the second issue, there is dumpbin.exe, but I find the Dependency Walker a little more friendly to use. These utilities will show you the functions that are exported from the DLL.

If it is discovered that the function was not exported, then you need to rebuild your DLL, ensuring that __declspec(dllexport) has been used on the function or class you're exporting.

Upvotes: 1

Related Questions