Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Lib vs DLL and Paths  (Read 2594 times)

Kraythe

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 15
    • View Profile
Lib vs DLL and Paths
« on: November 09, 2005, 04:05:14 PM »

I am currently in the process of creating new project files for visual C++ 2005  Right now OIS currently builds as a LIB. I think it should build as a DLL. One reason is that possibly more than one application might be using OIS but that is a flimsy reason at best. =). The main reason is that if we release an upgrade to OIS, it will be much easier if the user can just upgrade the DLL and only has to recompile if we change the API.

Also I would like to have OIS use the includes and libs from the binary distribution of Ogre3d (via the OGRE_HOME environment var) One should not have to build the source of Ogre to work on OIS, expecially since OIS isnt targeted only at Ogre. In this case we are merely a customer of Ogre.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Lib vs DLL and Paths
« Reply #1 on: November 09, 2005, 04:50:52 PM »

Both ways (static and dll) have their uses.. So, I agree that OIS should build as a dll also. This can be done easily by just adding two more build targets in the main solution to build a debug/release dll. Of course, then there would also need to be OIS_EXPORT macro setup on classes to export them on Win32. - I can't remember if MinGW also needs exporting.. I think it can export all by default though - which is kindof a lost point right now, as there is no (working) project files for MinGW gcc builds yet.
Logged

Kraythe

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 15
    • View Profile
Lib vs DLL and Paths
« Reply #2 on: November 09, 2005, 05:45:54 PM »

I have done this already and the win32 project files are set up in VC++ 2005 to generate a DLL and an import library for that DLL.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Lib vs DLL and Paths
« Reply #3 on: November 09, 2005, 07:10:38 PM »

Is there some reason to seperate the VC7 and VC8 project files?

If not, I will add a comfiguration for DLL and add the Export macro there, as that way it can be used in VC7, 7.1, and 8.. VC6 is not supported out of the box :)
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Lib vs DLL and Paths
« Reply #4 on: November 09, 2005, 08:40:49 PM »

Ok, I've made the changes required to build both regular static libs (which are placed in ois/lib) and dlls with import libs (placed in /ois/dll).

This was not too easy of a task with having to make a config variable inside OISConfig.h that the client app must uncoment (or just define themselves before including any OIS headers). The reason being? Well, regular libs were having problems with client linking when using the __declspec stuff, and dll's needed that.

Now, I could have used a module definition file (.def) for the dll project.. however, do to c++ name mangling, this is not very easy, feasiable... So, if the user wants to use the dll, he must declare OIS_DYNAMIC_LIB before including any OIS headers (or, uncomment that line in OISConfig.h). No rebuild is required for that, as the OIS_RELEASE_DLL & OIS_DEBUG_DLL configurations define that themselves... But, whatever the user wants to do.
Logged

Anonymous

  • Guest
Lib vs DLL and Paths
« Reply #5 on: November 10, 2005, 02:08:40 AM »

Why so complicated. All you need on windows is the DLL and the import library.

As for the #ifdef macro, I made it already in in the headers. I merely followed the same way ogre did it and moved the platform variable configuration to the top of the file.

What we need to find right now is a way of working. If Im going to work on this project I will need to be able to either commit or we will have to agree to work on different things. If you and I are constantly changing the same files and both trying to implement the same features then there is little point for me to try to do anythign here.
Logged

Kraythe

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 15
    • View Profile
Lib vs DLL and Paths
« Reply #6 on: November 10, 2005, 02:10:46 AM »

Ack that was me again ...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Lib vs DLL and Paths
« Reply #7 on: November 10, 2005, 10:04:51 AM »

Yes, I agree with the commit part. I am doing nothing to keyboard, so you are free to do changes there.

As far as so complicated, it is not. From my testing, you cannot use the _OisExport defined as declspec( dllExport ) when building a static lib, so it defaults to _OisExport defined as nothing in that case. Only when OIS_DYNAMIC_LIB is defined (as it is in the release & debug dll configuration) does dllexport and import come into play. Now, any app wanting to use OIS as a dll has to either (a) define that OIS_DYNAMIC_LIB before including any OIS header, or change the OISConfig.h file. Not that hard.. Just not as easy as using the lib as a static lib.. as that is the default that I am wanting. As, the input lib does not need to be a dll, but there is a choice already there now, for anyone who does want that.

btw, I sent you a PM yesterday... guess it did not Pop Up and inform you?
Logged

Rackle

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 26
    • View Profile
Lib vs DLL and Paths
« Reply #8 on: November 11, 2005, 06:20:06 PM »

The ois\Win32\ois.sln projects use ois\lib as the directory for .lib but the ois_d.lib is placed in ois\dll and not in ois\lib.  Or maybe I retrieved a WIP cvs version.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Lib vs DLL and Paths
« Reply #9 on: November 11, 2005, 06:29:12 PM »

The ois/lib is where all static libs are placed (on Win32).

ois/dll Should contain both debug (ois_d.dll and import lib ois_d.lib) and release (ois.dll and import ois.lib).
Logged

Rackle

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 26
    • View Profile
Lib vs DLL and Paths
« Reply #10 on: November 11, 2005, 07:32:38 PM »

If I only select the "Solution 'oi' (5 projects)" and hit build then I only build the debug configuration and the ois_d.lib is only present in the dll directory.  However if I right-click and select batch build and "select all" then the ois_d.lib is present in both ois/dll and ois/lib.  Got it working now.
Logged