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. vc++ 4.0 and dll

vc++ 4.0 and dll

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
4 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.
  • W Offline
    W Offline
    wahchai
    wrote on last edited by
    #1

    i have created test_build.dll, xxx.h, xxx.def. next i created testexe to try calling functions inside that dll. but this testexe does not compile - error msg about unresolved external symbol... indicating it could not 'see' those functions inside the dll. question - what settings on this testexe project i need to set/un_set for it to work?

    _ 1 Reply Last reply
    0
    • W wahchai

      i have created test_build.dll, xxx.h, xxx.def. next i created testexe to try calling functions inside that dll. but this testexe does not compile - error msg about unresolved external symbol... indicating it could not 'see' those functions inside the dll. question - what settings on this testexe project i need to set/un_set for it to work?

      _ Offline
      _ Offline
      _Theo_
      wrote on last edited by
      #2

      There are two ways to do it: -link your testexe with a .lib file created when you compile the dll -use LoadLibrary and GetProcAddress to load the dll during execution of the test executable

      W 1 Reply Last reply
      0
      • _ _Theo_

        There are two ways to do it: -link your testexe with a .lib file created when you compile the dll -use LoadLibrary and GetProcAddress to load the dll during execution of the test executable

        W Offline
        W Offline
        wahchai
        wrote on last edited by
        #3

        i am a total amateur with vc++ so pls bear with me... >-link your testexe with a .lib file created when you compile the dll this would mean i am hard-wiring my .lib to the testexe build? >-use LoadLibrary and GetProcAddress to load the dll during execution of >the test executable with the following code("square" is on of the functions inside test_build.dll) FARPROC * lpfProcFn; HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); *lpfProcFn = GetProcAddress(&hLib, "square"); ?? how do i now call that "square" fn ?? abc = square(45); <-- compiler will complain unresolved fn... thanks.

        _ 1 Reply Last reply
        0
        • W wahchai

          i am a total amateur with vc++ so pls bear with me... >-link your testexe with a .lib file created when you compile the dll this would mean i am hard-wiring my .lib to the testexe build? >-use LoadLibrary and GetProcAddress to load the dll during execution of >the test executable with the following code("square" is on of the functions inside test_build.dll) FARPROC * lpfProcFn; HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); *lpfProcFn = GetProcAddress(&hLib, "square"); ?? how do i now call that "square" fn ?? abc = square(45); <-- compiler will complain unresolved fn... thanks.

          _ Offline
          _ Offline
          _Theo_
          wrote on last edited by
          #4

          If your square function has for example the following definition: int square(int a,int b); you could do it this way: typedef int (*proc)(int a,int b); HINSTANCE hLib; hLib = LoadLibrary("test_build.dll"); proc fptr=(proc)GetProcAddress(hLib,"square"); abc=fptr(1,2);

          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