Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. VS 2008 Configuration For Libraries

VS 2008 Configuration For Libraries

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocomhelpquestionworkspace
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Certini
    wrote on last edited by
    #1

    I just recently tried to create a library and then use the library functions within a simple console application. I followed the instructions at: http://www.functionx.com/visualc/libraries/staticlib.htm 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? --------------------------------------------------------------------------------

    M 1 Reply Last reply
    0
    • M Mike Certini

      I just recently tried to create a library and then use the library functions within a simple console application. I followed the instructions at: http://www.functionx.com/visualc/libraries/staticlib.htm 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? --------------------------------------------------------------------------------

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      You don't add the .lib file to the project, since it isn't a source file. Add the filename to the linker options, so it looks there for the library functions that you call.

      --Mike-- Dunder-Mifflin, this is Pam.

      M 1 Reply Last reply
      0
      • M Michael Dunn

        You don't add the .lib file to the project, since it isn't a source file. Add the filename to the linker options, so it looks there for the library functions that you call.

        --Mike-- Dunder-Mifflin, this is Pam.

        M Offline
        M Offline
        Mike Certini
        wrote on last edited by
        #3

        Mike, Thank you for your reply. Where do you add it? I added it to configuration properties\linker\general\additional library directories. I though am now getting LINK2019 for each of the functions. See below: Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Max(double const *,int)" (?Max@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Min(double const *,int)" (?Min@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Average(double const *,int)" (?Average@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Sum(double const *,int)" (?Sum@@YANPBNH@Z) referenced in function _main 1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

        T 1 Reply Last reply
        0
        • M Mike Certini

          Mike, Thank you for your reply. Where do you add it? I added it to configuration properties\linker\general\additional library directories. I though am now getting LINK2019 for each of the functions. See below: Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Max(double const *,int)" (?Max@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Min(double const *,int)" (?Min@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Average(double const *,int)" (?Average@@YANPBNH@Z) referenced in function _main 1>Exercise.obj : error LNK2019: unresolved external symbol "double __cdecl Sum(double const *,int)" (?Sum@@YANPBNH@Z) referenced in function _main 1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

          T Offline
          T Offline
          tagopi
          wrote on last edited by
          #4

          hello, in your project properties, linker/input, add your .lib file name. for eg. yourlibfile.lib this will solve your issue. Regards, A. Gopinath.

          M 1 Reply Last reply
          0
          • T tagopi

            hello, in your project properties, linker/input, add your .lib file name. for eg. yourlibfile.lib this will solve your issue. Regards, A. Gopinath.

            M Offline
            M Offline
            Mike Certini
            wrote on last edited by
            #5

            tagopi, This is the solution that was posted by WayneAKing in the Visual C++ Developer Center forum. His posting is in response to an error listing that 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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups