Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in building a DLL

Status
Not open for further replies.

Valius

Programmer
Oct 20, 2000
174
US
Hey guys, I'm wanting to build a DLL. This is the first time I've done it, so I need some help. I made a new project and made it a Win32 Dynamic-Link Library. I imported a .cpp and .h file and compiled it. It compiled fine and I got a .DLL file. But when I tried to #import it into my MFC program it gave me some error. I can't remember it now. It was something about it not being a correct library. Are there some setting that I need to use or set so that I can get it to work. It's a simple .DLL. All it is is a thin wrapper for the MSADOxx.DLL. Anyway, any help would be greatly appreciative. Thanks for your time!

Niky Williams
NTS Marketing, Inc.
 
Your dll must have a .tlb file if you want to #import. But a .tlb file is generated only for COM dll/exe files. It doesn't matter what you use or not COM in your dll. John Fill
1c.bmp


ivfmd@mail.md
 
Hmm...I thought when you did the #import it automatically created the .tlb and .tlh files. How else can I get my .dll into my project successfully and is there anything that you can think of that I would be missing? Thanks for your time!

Niky Williams
NTS Marketing, Inc.
 
I rebuilt the DLL and tried to import it into my project just to see what the error was that I got. It says:

fatal error C1083: Cannot open type library file: 'L:\SQL.dll': Error loading type library/DLL.

It's the whole "Error loading type library/DLL" that I don't understand. I'm thinking I built it wrong, had the wrong setting, or something along those lines. Thanks for your time!

Niky Williams
NTS Marketing, Inc.
 
I think I answered a similar post of yours about DLL errors.
It says that those errors are typically generated when the file has only read-access and not write, meaning it's on a CD-ROM, so move it to your hard disk.

I think you would get alot less errors if you moved all of your DLL,LIBS, and other project files to the same directory(folder) as the current project your working on. When Visual Studio (MS VC++) creates a new project it creates a folder for all of the generated files and your files. They are usually created in your MyDocuments folder under a sub-folder called VisualStudioProjects. I have my project folders created under the C: drive but I beleive defualt is the VisStudioProj folder. Go ahead and place all the files your gonna use for the project except for standard C++ and VC++ files in the folder of your proj. I think you'll find you'll get alot less trivial errors that way, which this error appears to be.

For future reference, you can find out what the error codes are trying to tell you by going to....


and search for the code it gave you (C1083).

Later.
 
the tlb is created while compilling a COM exe/dll server, especially on comopilling the idl file. If the tlb file exists and is registered well, the tlh and tli are generated automatically while #import. John Fill
1c.bmp


ivfmd@mail.md
 
Ion, that answer is for COM dll. You can't regsvr32 a dll what doesn't have a DllRegisterServer/DllUnregisterServer. However the dll has theese functions, and don't have a tlb file you can't #import it. John Fill
1c.bmp


ivfmd@mail.md
 
Hi...
I think sometimes #import gives problem...
Are u using some smart pointers after importing..???
Shall i tell u a shortcut.... u can add such files in yur workspace too..and then try to import...
hope this will solve yur problem...
 
What does #import have to do with smart pointers? you can #import only COM objects which have type libraries(.tlb). An ordinary dll you can use only with LoadLibrary/FreeLibrary or on building the project with its .lib and using its .h file. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top