Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with .dll's...  (Read 4553 times)

0 Members and 1 Guest are viewing this topic.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Help with .dll's...
« on: November 22, 2010, 02:51:38 am »
Ok well I have done a lot of coding recently that I could use in various projects and I want to know how to create a .dll that can be used in my project in debugging and in the final. I believe I have created a dll but I think I made it wrong. Help????? BTW i am using visual c++ 2010 expresses edition.

I have my classes such as Menu with a menu.h for declarations and menu.cpp for the actual functions and I just included the menu.h in my dll's cpp. And when I build it it built fine but I don't know if I build anything...

Also how do I use a dll once I have it??

Relic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Help with .dll's...
« Reply #1 on: November 22, 2010, 07:44:54 am »
To check if you have built your dll right you can look through exported functions (methods) that it must expose. For this purpose you can use a very convenient tool Dependency Walker http://www.dependencywalker.com/. It will show you a lot of useful information. I guess this tool is a must-have for windows programmers. To use your dll you should add your_dll_name.lib file to the link list in your project. And dont forget to include the header file with declarations of exported functions in your dll's client side source file where it must be included. Though, if you make dlls yourself i guess you know all this things.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Help with .dll's...
« Reply #2 on: November 22, 2010, 03:38:31 pm »
Quote from: "Relic"
To check if you have built your dll right you can look through exported functions (methods) that it must expose. For this purpose you can use a very convenient tool Dependency Walker http://www.dependencywalker.com/. It will show you a lot of useful information. I guess this tool is a must-have for windows programmers. To use your dll you should add your_dll_name.lib file to the link list in your project. And dont forget to include the header file with declarations of exported functions in your dll's client side source file where it must be included. Though, if you make dlls yourself i guess you know all this things.


cant i just use the dll without the lib?

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Help with .dll's...
« Reply #3 on: November 22, 2010, 04:56:04 pm »
Quote from: "Fierce_Dutch"

cant i just use the dll without the lib?


the lib tells your executable 'these functions are over here in this dll'. You do not need to distribute the lib with your dll's unless you want others to use your dlls

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Help with .dll's...
« Reply #4 on: November 22, 2010, 04:59:52 pm »
Quote from: "ratzlaff"
Quote from: "Fierce_Dutch"

cant i just use the dll without the lib?


the lib tells your executable 'these functions are over here in this dll'. You do not need to distribute the lib with your dll's unless you want others to use your dlls


Ok so i inlclude the lib that i found with my dll in the properties along with the other sfml stuff?

Is there just a tutorial I can follow? I Mean I am just confused with the whole .dll because I have two seperate systems i want to implement into this .dll so that mean's I have a menu.h with declarations and a menu.cpp with the actual functions. Now I want to put the actual functions from the into the .dll and include my menu.h So that whenever i start a new project and I include the header file and put the lib in the properties then it will load all the .cpp files which are now in the dll. I try this and it doesnt work...

Help?

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Help with .dll's...
« Reply #5 on: November 22, 2010, 05:07:46 pm »
Quote from: "Fierce_Dutch"
Ok well I have done a lot of coding recently that I could use in various projects and I want to know how to create a .dll that can be used in my project in debugging and in the final. I believe I have created a dll but I think I made it wrong. Help????? BTW i am using visual c++ 2010 expresses edition.


It has been my experience that the main thing that keeps a dll from being usable in a release mode project is the differences in runtime library used to create the dll vs the exe. The default debug runtime library is MDd wheras the release version is MD (Multi-threaded Dll)

This is what I do to make both debug and release modes compatible:

Preprocessor -> Preprocessor Definitions: change _DEBUG to NDEBUG
Code Generation -> Runtime Library: change to Multi-threaded DLL (/MD)

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Help with .dll's...
« Reply #6 on: November 22, 2010, 05:08:54 pm »
Quote from: "Fierce_Dutch"

Ok so i inlclude the lib that i found with my dll in the properties along with the other sfml stuff?


Yeah, put the directory in Linker->General->Additional Library Directories and the filename in Linker->Input->Additional Dependencies

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Help with .dll's...
« Reply #7 on: November 22, 2010, 05:09:24 pm »
Quote from: "ratzlaff"
Quote from: "Fierce_Dutch"
Ok well I have done a lot of coding recently that I could use in various projects and I want to know how to create a .dll that can be used in my project in debugging and in the final. I believe I have created a dll but I think I made it wrong. Help????? BTW i am using visual c++ 2010 expresses edition.


It has been my experience that the main thing that keeps a dll from being usable in a release mode project is the differences in runtime library used to create the dll vs the exe. The default debug runtime library is MDd wheras the release version is MD (Multi-threaded Dll)

This is what I do to make both debug and release modes compatible:

Preprocessor -> Preprocessor Definitions: change _DEBUG to NDEBUG
Code Generation -> Runtime Library: change to Multi-threaded DLL (/MD)



I edited my previous post. Help..

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Help with .dll's...
« Reply #8 on: November 22, 2010, 05:20:52 pm »
Quote from: "Fierce_Dutch"

Is there just a tutorial I can follow? I Mean I am just confused with the whole .dll because I have two seperate systems i want to implement into this .dll so that mean's I have a menu.h with declarations and a menu.cpp with the actual functions. Now I want to put the actual functions from the into the .dll and include my menu.h So that whenever i start a new project and I include the header file and put the lib in the properties then it will load all the .cpp files which are now in the dll. I try this and it doesnt work...

Help?


I would start by googling 'win32 dll tutorial'. Pay close attention when the articles start talking about __dllimport and __dllexport.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Help with .dll's...
« Reply #9 on: November 22, 2010, 06:03:18 pm »
Quote from: "ratzlaff"
Quote from: "Fierce_Dutch"

Is there just a tutorial I can follow? I Mean I am just confused with the whole .dll because I have two seperate systems i want to implement into this .dll so that mean's I have a menu.h with declarations and a menu.cpp with the actual functions. Now I want to put the actual functions from the into the .dll and include my menu.h So that whenever i start a new project and I include the header file and put the lib in the properties then it will load all the .cpp files which are now in the dll. I try this and it doesnt work...

Help?


I would start by googling 'win32 dll tutorial'. Pay close attention when the articles start talking about __dllimport and __dllexport.


Ok is there any other easier way I can do this?? It doesnt have to be dll

Relic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Help with .dll's...
« Reply #10 on: November 23, 2010, 08:20:47 am »
Quote
Ok is there any other easier way I can do this?? It doesnt have to be dll

If you dont have to use dlls, you may gather all your reusable code that you want to make use of in other projects into a static library. It must be another kind of VS project (set Application type: Static Library in application settings). After building the library project you will get your_lib_name.lib file. The linking to client projects is similar to described in the posts above.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Help with .dll's...
« Reply #11 on: November 26, 2010, 04:24:58 am »
Quote from: "Relic"
Quote
Ok is there any other easier way I can do this?? It doesnt have to be dll

If you dont have to use dlls, you may gather all your reusable code that you want to make use of in other projects into a static library. It must be another kind of VS project (set Application type: Static Library in application settings). After building the library project you will get your_lib_name.lib file. The linking to client projects is similar to described in the posts above.


So can I still distribute this program without dll's if I use static libraries?

Relic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Help with .dll's...
« Reply #12 on: November 26, 2010, 09:51:13 am »
Yes. But as for vc runtime libraries it depends on the settings in your library project and its dependencies projects. If they was compiled with Multi-threaded DLL (/MD) set, then you have to distribute vc runtime dlls with your application. Besides, there are two SFML's dependency dlls (libsndfile-1.dll and openal32.dll). If your application uses sfml-audio library, they must be distributed as well.

 

anything