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. C++ package objects into separate .dll class library projects

C++ package objects into separate .dll class library projects

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++graphicsgame-devdebugging
6 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.
  • T Offline
    T Offline
    TheGeneral69
    wrote on last edited by
    #1

    I have a 'Table' object (reads a text file to create a table and return table picks). I have moved the code into it's own class library project, and I wish to call the code in the .dll from the main app. The class library project compiles to a .dll, but I don't know how to add it to the main project. I have addded the header file to the main project, and put the .dll in the source directory and debug directories. How do I add a reference to the .dll? Do I use '#include' or '#using'? How do I declare / instantiate the object, etc. (my attempts broke the build). What are the basic steps to do this? Can I put both projects in the same solution? Both are in C++ / VS2005. THe main app is from the DirectX SDK April 2007. Thanks, Steve

    R 1 Reply Last reply
    0
    • T TheGeneral69

      I have a 'Table' object (reads a text file to create a table and return table picks). I have moved the code into it's own class library project, and I wish to call the code in the .dll from the main app. The class library project compiles to a .dll, but I don't know how to add it to the main project. I have addded the header file to the main project, and put the .dll in the source directory and debug directories. How do I add a reference to the .dll? Do I use '#include' or '#using'? How do I declare / instantiate the object, etc. (my attempts broke the build). What are the basic steps to do this? Can I put both projects in the same solution? Both are in C++ / VS2005. THe main app is from the DirectX SDK April 2007. Thanks, Steve

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      i think u want to export the class, table, from the dll and use in the application, IMHO, implicit linking is the best. how to export classes from a DLL?[^] may be useful. have a look to this Linking an Executable to a DLL [^]

      TheGeneral69 wrote:

      Can I put both projects in the same solution?

      yes.

      T 2 Replies Last reply
      0
      • R Rajkumar R

        i think u want to export the class, table, from the dll and use in the application, IMHO, implicit linking is the best. how to export classes from a DLL?[^] may be useful. have a look to this Linking an Executable to a DLL [^]

        TheGeneral69 wrote:

        Can I put both projects in the same solution?

        yes.

        T Offline
        T Offline
        TheGeneral69
        wrote on last edited by
        #3

        Thanks!

        1 Reply Last reply
        0
        • R Rajkumar R

          i think u want to export the class, table, from the dll and use in the application, IMHO, implicit linking is the best. how to export classes from a DLL?[^] may be useful. have a look to this Linking an Executable to a DLL [^]

          TheGeneral69 wrote:

          Can I put both projects in the same solution?

          yes.

          T Offline
          T Offline
          TheGeneral69
          wrote on last edited by
          #4

          I have read the article 'DLLs are simple: Part 2' and have successfully moved the code for my Table class into it's own project / .dll. The example was for VC++ 6.0, whereas my application is in VS 2005. The main difference was the 'Project > Settings > Link (tab)' -- this doesn't exist in VS2005. To add the .lib file to the project, I put it in the main project directory and right-clicked on the solution and added an existing item, for file type I had to select 'all file types *.*', and added the .lib file to the project. I put the .dll in the debug folder, where the .exe gets put after a build. What I haven't done yet is to add my .dll project to the main project. I plan to add a new class library to the main application project, and copy and paste the code from the .dll project into it, and hope that it creates a .dll file, a .lib file, and a .exe file. The hope is that I would then be able to take the .dll, .lib, and .h file and use it in other projects. The purpose of this was to create a fast distance function, which does not call the sqrt function. It takes two or three parameters and returns length of the 'hypotenuse' without using sqrt. With a lookup table of only three points, I get an accuracy of within 1.5%, more than good enough for my level of detail calculations. It will be interesting to see if my function is actually faster or not. Steve

          R 1 Reply Last reply
          0
          • T TheGeneral69

            I have read the article 'DLLs are simple: Part 2' and have successfully moved the code for my Table class into it's own project / .dll. The example was for VC++ 6.0, whereas my application is in VS 2005. The main difference was the 'Project > Settings > Link (tab)' -- this doesn't exist in VS2005. To add the .lib file to the project, I put it in the main project directory and right-clicked on the solution and added an existing item, for file type I had to select 'all file types *.*', and added the .lib file to the project. I put the .dll in the debug folder, where the .exe gets put after a build. What I haven't done yet is to add my .dll project to the main project. I plan to add a new class library to the main application project, and copy and paste the code from the .dll project into it, and hope that it creates a .dll file, a .lib file, and a .exe file. The hope is that I would then be able to take the .dll, .lib, and .h file and use it in other projects. The purpose of this was to create a fast distance function, which does not call the sqrt function. It takes two or three parameters and returns length of the 'hypotenuse' without using sqrt. With a lookup table of only three points, I get an accuracy of within 1.5%, more than good enough for my level of detail calculations. It will be interesting to see if my function is actually faster or not. Steve

            R Offline
            R Offline
            Rajkumar R
            wrote on last edited by
            #5

            TheGeneral69 wrote:

            The main difference was the 'Project > Settings > Link (tab)' -- this doesn't exist in VS2005. To add the .lib file to the project, I put it in the main project directory and added the .lib file to the project

            projectproperty->linker->input->Additional Dependencies = <libname> projectproperty->linker->General->Additional Library Directories = <path to libfile>

            TheGeneral69 wrote:

            What I haven't done yet is to add my .dll project to the main project.

            TheGeneral69 wrote:

            copy and paste the code from the .dll project into it, and hope that it creates a .dll file, a .lib file, and a .exe file

            just add your dll project to your main project solution.

            TheGeneral69 wrote:

            The hope is that I would then be able to take the .dll, .lib, and .h file and use it in other projects.

            yes. you can.

            T 1 Reply Last reply
            0
            • R Rajkumar R

              TheGeneral69 wrote:

              The main difference was the 'Project > Settings > Link (tab)' -- this doesn't exist in VS2005. To add the .lib file to the project, I put it in the main project directory and added the .lib file to the project

              projectproperty->linker->input->Additional Dependencies = <libname> projectproperty->linker->General->Additional Library Directories = <path to libfile>

              TheGeneral69 wrote:

              What I haven't done yet is to add my .dll project to the main project.

              TheGeneral69 wrote:

              copy and paste the code from the .dll project into it, and hope that it creates a .dll file, a .lib file, and a .exe file

              just add your dll project to your main project solution.

              TheGeneral69 wrote:

              The hope is that I would then be able to take the .dll, .lib, and .h file and use it in other projects.

              yes. you can.

              T Offline
              T Offline
              TheGeneral69
              wrote on last edited by
              #6

              ahh, I saw that linker dialogue, but didn't know how to set it up. thanks again!

              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