Hi,

I am trying to make and use my own DLL within a C++/CLI project.

The DLL project contains an header utc.h file with the following declaration:

namespace utc
 {
      __declspec(dllexport) void dthr (int dt[3], int hr[3]);
 }

The source of the dthr.cpp file starts with:

namespace utc
{
__declspec(dllexport) void dthr (int dt[3], int hr[3])
   {
   }
}

The build of the utc.dll file is successful.

Within a Forms C++/CLI project, I have a WriteToLog.cpp file that starts with:

#include "stdafx.h"
#include "utc.h"

using namespace utc;

void WriteToLog(String ^mess)
{
  int dt[3], hr[3];

  dthr(dt, hr);

WriteToLog compiles fine. Using the "Properties -> Framework and references" dialog, I have added utc.dll as a reference.

But the linker does not find dthr().

What am I missing?

As a side question, it seems that I cannot use a static C++ .lib file with a C++/CLI application: the add Reference dialog does not support .lib files.

Is there another way to use a .lib file? I would prefer that to using a DLL.

Thanks.

Recommended Answers

All 7 Replies

I think the solution to your problem is found in this thread.

Edit: I found out how to use .lib static libraries.

Static libraries are not DLL's.

DLL's are Dynamic Libraries, which is more the opposite of static libraries.

So if you're linking a static library, and then thinking "woot now it's collecting data from my DLL", then you're wrong. Try deleting the DLL, your program won't complain that it is missing a DLL :)

Just fyi.

So if you're linking a static library, and then thinking "woot now it's collecting data from my DLL", then you're wrong. Try deleting the DLL, your program won't complain that it is missing a DLL :)

No, I wasn't doing that. I was linking a DLL by referencing it, but members of the DLL are not found, I end up with build errors.

You have to include the library, which is also output when you build DLL.
That library isn't a static library, but it just tells your project what content there is in the DLL.

You have to include the library, which is also output when you build DLL.
That library isn't a static library, but it just tells your project what content there is in the DLL.

Aaah!

Thanks, I would never had guessed that I needed to reference the .DLL file first, and then to include the .lib file.

You're welcome :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.