Archived

This topic is now archived and is closed to further replies.

WhatEver

Can someone help me make a dll, and lib file

Recommended Posts

I''ve been programming for almost 5 years, and I''ve never really had a use for dll''s, but now I do so I can release my model library for you guys. I have MSVC 6.0. I''ve created an empty dll project, and then added all my cpp, h and external lib files. When I compile a realeas dll and lib, and then try to use the lib in my game, I get this error:
quote:
Linking... .\rm\Release\rm.dll Release\rm.lib : fatal error LNK1136: invalid or corrupt file Error executing link.exe.
Can someone take me through the steps to making a dll/lb combo that works?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just a guess: Try to remove te dot and/or the whitespace from the pathname:

.\rm\Release\rm.dll Release\rm.lib
to
.\rm\Release\rmdllRelease\rm.lib

Might work!?!

Share this post


Link to post
Share on other sites
quote:
Linking...
.\rm\Release\rm.lib : fatal error LNK1136: invalid or corrupt file
Error executing link.exe.


It didn''t work .

Share this post


Link to post
Share on other sites
I finally got the reall lib file to export. Now when I link it to my game I get this error:

quote:
Linking...
actors.obj : error LNK2001: unresolved external symbol "public: __thiscall rmdata::rmdata(void)" (??0rmdata@@QAE@XZ)

Share this post


Link to post
Share on other sites
I''ve been trying to figure this out for the past 7 hours now, and it''s still a no go.

Can someone do this for me.

1) Make a dll project in MSVC++ 6.0 that creates one function called StrCpy, and does exactly what strcpy does.
2) Make a simple console application or non MFC application that imports the lib file created from the above project, and uses the StrCpy.

This would help me tremendously.

Share this post


Link to post
Share on other sites
Nobody here knows how to make a dll? Whoa! Can anybody refur me to a Message Board that does so I can continue with my project?

Share this post


Link to post
Share on other sites
I succeded creating a dll/lib now. My next question now, is what are you aloud to export? Just functions? I can''t seem to export class functions, can you even do this? I got an error when I tried to export an overloaded function.

Bad thing is that my game locked when I used the dll . I''ll have to try the next example in a stand alone program specificly for practice.

One more thing. It seems I have to export EVERYTHING. Meaning prototypes and all. The header files for OpenGL like gl.h don''t have a export code in it at all? How are they doing it without exporting in the header file? Same goes for all of Q3As source code dlls.

Share this post


Link to post
Share on other sites
Try looking at the MSDN section on dlls. (I don''t have it rite now so I can''t point you directly to it)

Share this post


Link to post
Share on other sites
You can export classes essentially the same way you export functions, for example:

class __declspec(dllexport) MyExportedClass
{


};


Since you often want the DLL-using application to use the same include file information that was used to build the DLL, you might want to also use a conditional define, such as:


# ifdef BUILDING_DLL
# define DLLIMPORT __declspec(dllexport)
# else
# define DLLIMPORT
# endif

class DLLIMPORT MyExportedClass
{
/* define your class here */
};

Then, in the project settings for the DLL build (go to Project/Settings menu, click C/C++ tab, select ''Preprocessor'' as Category, and in the ''Preprocessor Definitions'' textbox, add BUILDING_DLL to the (comma-seperated) list. (it should already include WIN32,_WINDOWS and perhaps DEBUG if you are in debug configuration.

This will allow you to include the same header file from your other projects which use the DLL, and they will just ignore the dll export information which would otherwise confuse them.

Share this post


Link to post
Share on other sites
I''m having a problem. I got the classes to export (I think), but now I''m getting errors with an external variable name when I link the lib to my game.

It looks kinda like this:

//---test.h---
__declspec(dllexport) int nVertices;



//---test.cpp---
__declspec(dllexport) extern int nVertices;


I get an "unresolved external symbol" error when I link it to my game.

Share this post


Link to post
Share on other sites
If you are trying to import the variables to your game you should not use the __declspec(dllexport). And remember to link with the export library. And also make sure that the variable is actually exported.

You can find alot of information about this at MSDN, thats what i did. Until yesterday i didnt know anything about using DLL''s, but i found alot of information on MSDN and everything worked the first time.
Just go to www.msdn.microsoft.com and search for Dynamic-Link-Libraries or __declspec.

Hope this helps.

Share this post


Link to post
Share on other sites