CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    How I use global variable defined in EXE module in DLL ?

    Hi,
    How I use anyone global variable declared in EXE module in DLL ? After declare it in DLL I have error "LNK2001: unresolved external symbol"
    Thanks


  2. #2
    Guest

    Re: How I use global variable defined in EXE module in DLL ?

    You must put __declspec(dllexport) before the variable in the DLL and __declspec(dllimport) before the variable in the exe.

    kevin


  3. #3
    Guest

    Re: How I use global variable defined in EXE module in DLL ?

    In a DLL, you cannot use a variable defined in another module unless you import it. In your case, it is easy to define the variable in a new separate dll, make sure you export it (put declspec(dllexport) before the declaration). Then you can use the variable in your own dll and your executable, but make sure you import it (use declspec(dllimport) to declare the variable). You need to provide the import library (.lib file) generatd along with the new dll to link your own dll and your executable.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured