dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: DLL without LIB - a couple of questions

  1. #1
    Join Date
    Sep 2005
    Posts
    10

    DLL without LIB - a couple of questions

    Hey guys.... I'm sorry if my problem might seem easy or has been discussed before - I simply couldn't find anything helpful. So here it is.

    I have to port a bunch of C++ code from Sun to Windows and I'm having some major issues. First, I have to create a couple of DLLs, and then, using these libraries, I have to create a console application. All the code exists and works on Sun.

    Anyways, here are my questions:
    - Whenever I create a new DLL project (I'm using VS6), I successfully compile the code, but I only get as result the DLL file, without any associated LIB file. Any idea why this is happening? Maybe I'm screwing up some setting?
    - Is there any way to include the library in the console application by only using the DLL (without the LIB file)?

    So far everything I tried ended up with "unresolved external symbol" errors. I also tried creating only LIBs (not DLLs) and including them in the console app - same result.

    Any ideas?

    Thanks a lot for your help.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: DLL without LIB - a couple of questions

    Quote Originally Posted by cristane View Post
    - Is there any way to include the library in the console application by only using the DLL (without the LIB file)?
    You don't need a LIB file for any DLL.

    Look at LoadLibrary() and GetProcAddress(). These functions load and obtain the pointer to the exported DLL functions at run-time. By using these functions, the LIB file is no longer necessary.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Sep 2005
    Posts
    10

    Re: DLL without LIB - a couple of questions

    Quote Originally Posted by Paul McKenzie View Post
    You don't need a LIB file for any DLL.

    Look at LoadLibrary() and GetProcAddress(). These functions load and obtain the pointer to the exported DLL functions at run-time. By using these functions, the LIB file is no longer necessary.

    Regards,

    Paul McKenzie
    Thanks for the fast response.

    I wouldn't want to use those functions because I just want to port the code without modifying it too much if it's possible. This is why I was wondering about the LIB issue and how I can solve it - maybe if I can get the lib files and include them properly it will be enough.

    Cristian

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,603

    Re: DLL without LIB - a couple of questions

    Quote Originally Posted by cristane View Post
    - Whenever I create a new DLL project (I'm using VS6), I successfully compile the code, but I only get as result the DLL file, without any associated LIB file. Any idea why this is happening? Maybe I'm screwing up some setting?
    In DLL project, you have a lib file only when you export something from your dll. So, did you? Afraid you didn't, otherwise you'd have your lib alright.

    - Is there any way to include the library in the console application by only using the DLL (without the LIB file)?

    So far everything I tried ended up with "unresolved external symbol" errors. I also tried creating only LIBs (not DLLs) and including them in the console app - same result.
    As long as this is you who builds the dll, there's no need to go any other hard way. Just make sure you build the dll along with its lib.

    BTW, your last statement about creating LIBs and failing to include them to another app sounds unbelievable. You definitely miss some important point. The sample would be good. (Please avoid posting the full-blown solution, neither you nor us need that. Just something neutral would be okay.)

    Another thing just crossed my mind. I believe, this is your first time you deal with dlls. Did you make some really little solution where you just try to grab the concept? Like one-function/one-export dll used in a couple-of-lines application, console, whatever? Did you? It's very useful training, you know.
    Last edited by Igor Vartanov; November 20th, 2009 at 06:29 AM.
    Best regards,
    Igor

  5. #5
    Join Date
    Aug 2009
    Posts
    8

    Re: DLL without LIB - a couple of questions

    VS6 should create the lib as well as the dll. I have never come across this before. If you have solved the problem please explain how.

    If not have you tried compiling the files using the command line compiler? Try the cl.exe at http://codediaries.blogspot.com/2009...mple-with.html to see if it works

  6. #6
    Join Date
    Feb 2002
    Posts
    4,640

    Re: DLL without LIB - a couple of questions

    Quote Originally Posted by righteous View Post
    VS6 should create the lib as well as the dll. I have never come across this before. If you have solved the problem please explain how.

    If not have you tried compiling the files using the command line compiler? Try the cl.exe at http://codediaries.blogspot.com/2009...mple-with.html to see if it works
    If you do not have any exported functions/variables, the compiler will not create the .lib file (there's no need to). Igor already mentioned this.

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)