calling a DLL, using MS VC++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Suzanne Vogel

    calling a DLL, using MS VC++

    Hi,

    I'm trying to call a DLL that I created using Microsoft Visual C++, and
    ascertain that I created the DLL properly. I've never created a DLL
    before, and the Microsoft documentation does not help me:

    Also, if possible, I want to avoid using the Visual C++ wizard to create
    a DLL, because that creates several files and extra lines of code.

    Below is my test code. The first file creates a DLL with the function
    "printHello ()". The second file, the "main" program, tries to call that
    function in the DLL. I believe the main program *could* find the DLL,
    and that there is merely something wrong with my C++ syntax: I
    remembered to put the DLL into the directory where the executable for
    the main program was to be created, and set the PATH variable to search
    the current "." directory.

    ** What is causing my DLL link error?

    Thanks,
    Suzanne

    ------------------------------------------
    #include <stdlib.h>
    #include <iostream>

    __declspec(dlle xport) println(char* s);

    __declspec(dlle xport) void printHello() {
    std::cout << "Hello world\n";
    }
    ------------------------------------------
    #include <stdlib.h>

    __declspec(dlli mport) void printHello();

    int main(int argc, char** argv) {
    void (*f)() = &printHello;
    f(); // Link error!!!

    return EXIT_SUCCESS;
    }

  • Victor Bazarov

    #2
    Re: calling a DLL, using MS VC++

    "Suzanne Vogel" <suzanne_e_voge l@hotmail.com> wrote...[color=blue]
    > I'm trying to call a DLL that I created using Microsoft Visual C++, and
    > ascertain that I created the DLL properly. [..][/color]

    It's not your first day here, is it? Don't you already know
    that MS-specific questions are off-topic here? Please visit
    microsoft.publi c.vc.language.


    Comment

    • Suzanne Vogel

      #3
      Re: calling a DLL, using MS VC++

      > It's not your first day here, is it? Don't you already know[color=blue]
      > that MS-specific questions are off-topic here? Please visit
      > microsoft.publi c.vc.language.[/color]

      Got it. Sorry.

      Comment

      Working...