explicit library file

This is a discussion on explicit library file within the C++ Programming forums, part of the General Programming Boards category; Hi, I have a general question. This will only compile when I include winMM.lib as part of the project, i.e. ...

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359

    explicit library file

    Hi, I have a general question. This will only compile when I include winMM.lib as part of the project, i.e. the file is included within the solution explorer. I call the function waveOuGetNumDevs(); which is defined in MMSystem.h and is automatically included when you include windows.h and the library is winMM.lib. However, I should not have to explicitly include the winMM.lib within my project. I have checked all the library paths which the linker will search through when looking for winMM.lib to match it with the declaration from MMSystem.h, and the correct path is there. I have not had to do this with any other of my function calls in my project, the linker has always been able to match the header with the lib fine. Within the project file visual studio has included this

    <File
    RelativePath="C:\Program Files\Microsoft SDK\Lib\WinMM.Lib">
    </File>
    Now, if I remove this lib file from the project again, a linker error will be given again. Here below is a basic snippet:


    Code:
    #include <tchar.h>
    #include <windows.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
      unsigned a = waveInGetNumDevs();
      return 0;
    }
    Be a leader and not a follower.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    >> However, I should not have to explicitly include the winMM.lib within my project...
    You have to tell the linker about all LIB files to look at for resolving external symbols. IDE's typically include all "basic" LIB's by default.

    >> I have checked all the library paths which the linker will search through when looking for winMM.lib
    The linker will only search for winMM.lib if you have told it to do so.

    >> to match it with the declaration from MMSystem.h
    The linker doesn't know about any header files in your application. However, some compilers support custom pre-processing directives for specifying linker options and library files to link against.

    gg

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    The linker will only search for winMM.lib if you have told it to do so.
    Surely, if I have included the path within the VC++ directories under library files, then the linker should search that path for the library file it requires, therefore you are telling it to do so. I have included a screen shot with the path included for the linker to search through, and it is circled in red. The file is in that directory.... so why cant it find it?
    Attached Images Attached Images  
    Be a leader and not a follower.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    >> Surely, ... the linker should search that path for the library file it requires
    Linkers do not typically "search" for anything. You give it a file, like winMM.lib, and one or more directories where it can find that file. In other words, the linker will only look at .LIB files you specify, nothing more. Any directories you specify are only so the linker can find .LIB files you have specified.
    And don't call me Surely

    gg

  5. #5
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Ok, so how can I tell the linker where this lib file is located without haveing a relative path included in the project file...

    :RelativePath="C:\Program Files\Microsoft SDK\Lib\WinMM.Lib">

    Or is the only way to tell the linker where the file is?
    Be a leader and not a follower.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    I don't use VC++ .NET, but I'm sure someone will be able to help you (bump).

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 09:47 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21