开发者

Linking DLL with .DEF or .LIB file

开发者 https://www.devze.com 2023-04-06 01:41 出处:网络
Caution: I know nothing about C++. I\'m comfortable using C#, but this is confusing the hell out of me.

Caution: I know nothing about C++. I'm comfortable using C#, but this is confusing the hell out of me.

I know this is a common question, but I've spent the last few hours very frustrated - mainly because it's something that should be really simple.

I'm trying to import a DLL into VC++ 2010, and for the life of me I can't figure out the 'nice' way to do it. I have the headers that contain definitions, and a .DEF file that I've converted into a .lib file using the "lib".

All I want to do is to be able to call the functions contained within a DLL! When I try to add it as a reference, I get the following error: Could not add a reference to file WindowsAccessBridge.dll, because it is neither a .NET assembly nor a registered ActiveX control.

I can access the functions with LoadLibrary/GetProcAddress, but I was really hoping for a 'drop in' solution that wouldn't mean I have to write code for 50+ functions.

TL;DR: How do I import a native C++ dll into my project, in order to call its functions? I have the .lib, .def, and .dll file. Your move?

Edit - I realise the correct answer would be "Learn the language you're trying to write in." - b开发者_Python百科ut I'm really hoping there's a simple way to get this done.

Code:

#include "StdAfx.h"
#include "WABAPI.h"
#include "AccessBridgeCalls.h"

WABAPI::WABAPI(void)
{
}

void WABAPI::Init()
{
    initializeAccessBridge();
}

Here are my settings in Linker:

Linking DLL with .DEF or .LIB file


You include the header into your source code:

#include <your_header.h>

Then you tell the linker to use the .lib file:

Linking DLL with .DEF or .LIB file

This picture is from VS 2008, but if memory serves, the layout in VS 2010 is similar.

0

精彩评论

暂无评论...
验证码 换一张
取 消