• Advertisement
Sign in to follow this  

DLLs using DLLs

This topic is 2560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Resolved: Always remember to include your .lib in the project, not just put it in your project folder. :P

I'm trying to use .DLLs for the first time. I've successfully used a test .DLL in a test project, using a lib in the project directory at compile time as needed. Now, I'm attempting to create another .DLL which calls a function from the first one. I've put the .lib with the project and I get a linker error for using the supposedly imported function. Can I even use a .DLL function in another .DLL? I'll post the code below, exept for the DllMain() that was generated as part of a standard visual studio dll project.

1st dll:
-----------------------------
// Exported function - adds two numbers
extern "C" __declspec(dllexport) double AddNumbersInDLL(double a, double b )
{
return a + b;
}


2nd dll:
-----------------------------
// Import function that adds two numbers
extern "C" __declspec(dllimport) double AddNumbersInDLL(double a, double b );

// Exported function - add then subtract numbers
extern "C" __declspec(dllexport) double AddThenSubtractNumbersInDLL(double a, double b, double c)
{
return AddNumbersInDLL(a + b ) - c;
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement