Thread: VS 2008 Configuration For Libraries

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    27

    VS 2008 Configuration For Libraries

    I just recently tried to create a library and then use the library functions within a simple console application. I followed the instructions at:

    Visual C++ Examples: Static Libraries

    After copying the "lib" and "h" file into the source file directory for the program, I got a linking error. I added these files to the project via "Add Existing Item" menu selection. The error I got was the following:

    A custom build rule to build files with extension 'lib' could not be found.

    Would you like to create a new rule to define a custom build rule to build files with this extension?

    I would think that using library functions would be a standard functionality for Visual C. Is there a setting somewhere that has to be adjusted to allow for this functionality? If not, does anyone know the rule that needs to be used?

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Did you name both header and cpp file, the same name?

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    27
    Mr. 777,

    No they have different names.

  4. #4
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    That is the problem then...
    Example:
    test.h is the name of your header file.
    you should make the .cpp file in which you will implement all the functions that are defined in header file and save it as test.cpp
    Finally make your main class with any name to use these functions...

    Your problem will be solved..

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Uhh, what silly tutorial is this which does not do it right?
    You can't add lib files to the project.
    You go into project settings -> C/C++ -> linker -> input and add it under extra libraries or whatever it's named.

    Nothing else.
    Boo to this code. Bloody C+ programmers.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    27

    Solution

    Elysia,

    This is the solution that was posted by WayneAKing in the Visual C++ Developer Center forum. This is his response to an error message I posted. This guy knows everything. My program is now working.

    I added the directory to the project configuration
    >properties - linker - general tab.

    That's half the requirements.

    What did I say to add, and where did I say to add it?
    Look under Linker->Input for "Additional Dependencies"
    and add your .lib filename to the list.

    >int main()

    You are making a console program.

    >error LNK2019: unresolved external symbol _WinMain@16
    >referenced in function ___tmainCRTStartup

    WinMain is used with Win32 GUI applications, not console apps.
    How did you create the project? Which project template did
    you use? You should have selected "Win32 Console Application".

    Look under Linker->System for "SubSystem" and set it to
    "Console (/SUBSYSTEM:CONSOLE)"

    - Wayne

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 01:24 PM
  2. Generic configuration module
    By linux454 in forum C++ Programming
    Replies: 0
    Last Post: 01-30-2006, 11:44 PM
  3. Configuration Files
    By gvector1 in forum C# Programming
    Replies: 1
    Last Post: 10-30-2003, 04:21 PM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM