Results 1 to 4 of 4

Thread: unresolved Externals in a dll

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    Question unresolved Externals in a dll

    Well again I don't have a clue.

    I'm trying to export some functions from a dll into my app, but I am getting these errors:

    key32.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __stdcall InitHooksDll(struct HWND__ *,int)" (__imp_?InitHooksDll@@YGHPAUHWND__@@H@Z)
    key32.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __stdcall PaintHooksDll(struct HDC__ *)" (__imp_?PaintHooksDll@@YGHPAUHDC__@@@Z)
    key32.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __stdcall InstallFilter(int,int)" (__imp_?InstallFilter@@YGHHH@Z)

    could somebody explain why i get them and how to solve them?! I'm pretty lost to tell the truth! and the help provided by msdn and the likes is not the greatest for a beginer like myself!

    I've enclosed my code, you have to run it from the d:\development\key32\ directory as there are includes with path statements!! (is there anyway round this type of include statement? i.e. #include "d:\development....\key32.h"

    Cheers in advance

    Andy
    Attached Files Attached Files

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    As for the includes, in Project Settings you can add another path to the list of include paths for that project (this is per-configuration, by the way).

    For CREATING the DLL, you need to use __declspec(dllexport), and __declspec(dllimport) for USING the DLL. This means that you need to define a macro based on the project settings. See the other DLL threads for this
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    ??? i thought i had done that

    I thought i had already put that stuff in:

    #ifndef __KEYDLL_H__
    #define __KEYDLL_H__

    #include <windows.h>

    #ifdef _DLL_INTERNAL_
    #define DLLEXPORT __declspec(dllexport)
    #else
    #define DLLEXPORT __declspec(dllimport)
    #endif

    int DLLEXPORT WINAPI InitHooksDll(HWND hwndMainWindow, int nWinLineHeight);
    int DLLEXPORT WINAPI PaintHooksDll(HDC hDC );
    int DLLEXPORT WINAPI InstallFilter (int nHookIndex, int nCode );
    char DLLEXPORT *szMessageString(int ID);

    #endif // __KEYDLL_H__


    do i need to put it somewhere else in my code as well?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    when you create the dll, it should also create a file named "keydll.lib"
    You have to add this file under Linker->Object/Library Modules in the project settings.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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