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: 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? --------------------------------------------------------------------------------
-
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? --------------------------------------------------------------------------------
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.
-
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.
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
-
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
-
hello, in your project properties, linker/input, add your .lib file name. for eg. yourlibfile.lib this will solve your issue. Regards, A. Gopinath.
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