Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Linker error: LNK2001 with GetModuleBaseName and EnumProcessModule

Linker error: LNK2001 with GetModuleBaseName and EnumProcessModule

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Janine
    wrote on last edited by
    #1

    Hello, I'm trying to use GetModuleBaseName and EnumProcessModules, but I'm doing something wrong because I get linker error 2001. I guess that the problem is with WINAPI. I have a .c file that is forced to be compiled as c++ and I call those functions from there like this: EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleBaseName(hProc, hMod, pParentName, sizeof(pParentName)); Then I'm using PSAPI.h where I have -- clip -- #ifdef __cplusplus extern "C" { #endif -- clip -- BOOL WINAPI EnumProcesses( DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded ); -- clip -- DWORD WINAPI GetModuleBaseNameA( HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize ); DWORD WINAPI GetModuleBaseNameW( HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize ); #ifdef UNICODE #define GetModuleBaseName GetModuleBaseNameW #else #define GetModuleBaseName GetModuleBaseNameA #endif // !UNICODE -- clip -- #ifdef __cplusplus } #endif -- clip -- Now I get: myprogram.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16 myprogram.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16 Why? :confused: I've read many examples and it seems to me that I'm doing this in the same way as they do. I would be glad if someone helped me with this.:) -Janetta

    P 1 Reply Last reply
    0
    • J Janine

      Hello, I'm trying to use GetModuleBaseName and EnumProcessModules, but I'm doing something wrong because I get linker error 2001. I guess that the problem is with WINAPI. I have a .c file that is forced to be compiled as c++ and I call those functions from there like this: EnumProcessModules(hProc, &hMod, sizeof(hMod), &cbNeeded); GetModuleBaseName(hProc, hMod, pParentName, sizeof(pParentName)); Then I'm using PSAPI.h where I have -- clip -- #ifdef __cplusplus extern "C" { #endif -- clip -- BOOL WINAPI EnumProcesses( DWORD * lpidProcess, DWORD cb, DWORD * cbNeeded ); -- clip -- DWORD WINAPI GetModuleBaseNameA( HANDLE hProcess, HMODULE hModule, LPSTR lpBaseName, DWORD nSize ); DWORD WINAPI GetModuleBaseNameW( HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize ); #ifdef UNICODE #define GetModuleBaseName GetModuleBaseNameW #else #define GetModuleBaseName GetModuleBaseNameA #endif // !UNICODE -- clip -- #ifdef __cplusplus } #endif -- clip -- Now I get: myprogram.obj : error LNK2001: unresolved external symbol _GetModuleBaseNameA@16 myprogram.obj : error LNK2001: unresolved external symbol _EnumProcessModules@16 Why? :confused: I've read many examples and it seems to me that I'm doing this in the same way as they do. I would be glad if someone helped me with this.:) -Janetta

      P Offline
      P Offline
      Prem Kumar
      wrote on last edited by
      #2

      Ok, it is a linker error ! Come on, its the most common of the linker errors !. You forgot to include the psapi.lib in your linker tab.

      J 1 Reply Last reply
      0
      • P Prem Kumar

        Ok, it is a linker error ! Come on, its the most common of the linker errors !. You forgot to include the psapi.lib in your linker tab.

        J Offline
        J Offline
        Janine
        wrote on last edited by
        #3

        It is very common, but there are many reasons why you get it. Maybe this mistake was trivial, but it was new to me. Thank you anyway:) -Janetta

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups