C++ package objects into separate .dll class library projects
-
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
-
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
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.
-
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.
Thanks!
-
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.
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
-
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
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.
-
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.
ahh, I saw that linker dialogue, but didn't know how to set it up. thanks again!