I get linker errors while trying to compile a project together with my own static library.
I put the project's code generation to Multithreaded (/MT), and put msvcrtd into the list of libraries to ignore.
This gets me down to 8 errors, but I can't get those errors away.
1>------ Rebuild All started: Project: TSOClient, Configuration: Release Win32 ------
1>Deleting intermediate and output files for project 'TSOClient', configuration 'Release|Win32'
2>------ Rebuild All started: Project: AssetManager, Configuration: Release Win32 ------
2>Deleting intermediate and output files for project 'AssetManager', configuration 'Release|Win32'
2>Compiling...
1>Compiling...
2>Archive.cpp
1>Main.cpp
2>FARArchive.cpp
2>.\FARArchive.cpp(82) : warning C4482: nonstandard extension used: enum 'GameType' used in qualified name
2>.\FARArchive.cpp(182) : warning C4482: nonstandard extension used: enum 'GameType' used in qualified name
2>.\FARArchive.cpp(188) : warning C4482: nonstandard extension used: enum 'GameType' used in qualified name
2>DBPFArchive.cpp
2>BinaryStream.cpp
2>Creating library...
1>Linking...
2>Build log was saved at "file://c:\Users\Afr0\Documents\Visual Studio 2008\Projects\TSO\AssetManager\AssetManager\Release\BuildLog.htm"
2>AssetManager - 0 error(s), 3 warning(s)
1>AssetManager.lib(FARArchive.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in libcpmt.lib(string.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libcpmt.lib(string.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in basic3D.lib(DBOFormat.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in libcpmt.lib(string.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in Main.obj
1> Creating library Release\TSOClient.lib and object Release\TSOClient.exp
1>AssetManager.lib(FARArchive.obj) : warning LNK4217: locally defined symbol __invalid_parameter imported in function "public: struct FAREntry const & __thiscall std::list<struct FAREntry,class std::allocator<struct FAREntry> >::_Const_iterator<1>::operator*(void)const " (??D?$_Const_iterator@$00@?$list@UFAREntry@@V?$allocator@UFAREntry@@@std@@@std@@QBEABUFAREntry@@XZ)
1>AssetManager.lib(FARArchive.obj) : warning LNK4217: locally defined symbol ??1exception@std@@UAE@XZ (public: virtual __thiscall std::exception::~exception(void)) imported in function __unwindfunclet$??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z$0
1>AssetManager.lib(FARArchive.obj) : warning LNK4217: locally defined symbol ??0exception@std@@QAE@XZ (public: __thiscall std::exception::exception(void)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
1>AssetManager.lib(FARArchive.obj) : warning LNK4217: locally defined symbol ??0exception@std@@QAE@ABV01@@Z (public: __thiscall std::exception::exception(class std::exception const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::logic_error const &)" (??0logic_error@std@@QAE@ABV01@@Z)
1>AssetManager.lib(FARArchive.obj) : warning LNK4217: locally defined symbol ??0exception@std@@QAE@ABQBD@Z (public: __thiscall std::exception::exception(char const * const &)) imported in function "public: __thiscall std::bad_alloc::bad_alloc(char const *)" (??0bad_alloc@std@@QAE@PBD@Z)
1>AssetManager.lib(FARArchive.obj) : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: struct FAREntry const & __thiscall std::list<struct FAREntry,class std::allocator<struct FAREntry> >::_Const_iterator<1>::operator*(void)const " (??D?$_Const_iterator@$00@?$list@UFAREntry@@V?$allocator@UFAREntry@@@std@@@std@@QBEABUFAREntry@@XZ)
1>AssetManager.lib(BinaryStream.obj) : error LNK2019: unresolved external symbol __imp___wassert referenced in function "public: __thiscall BinaryStream::BinaryStream(char * * const)" (??0BinaryStream@@QAE@QAPAD@Z)
1>Release\TSOClient.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Users\Afr0\Documents\Visual Studio 2008\Projects\TSO\TSOClient\TSOClient\Release\BuildLog.htm"
1>TSOClient - 8 error(s), 6 warning(s)
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Here's how the only file in my project looks, if it helps anyone:
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 2D project that uses Dark GDK
// it can be used as a starting point in making your own 2D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "AssetManager\FARArchive.h"
#pragma comment(lib, "AssetManager")
// the main entry point for the application is this function
void DarkGDK ( void )
{
// in this application a backdrop is loaded and then several
// animated sprites are displayed on screen
// when starting a Dark GDK program it is useful to set global
// application properties, we begin by turning the sync rate on,
// this means we control when the screen is updated, we also set
// the maximum rate to 60 which means the maximum frame rate will
// be set at 60 frames per second
dbSyncOn ( );
dbSyncRate ( 60 );
FARArchive m_Archive("other.dat");
// a call is made to this function so we can stop the GDK from
// responding to the escape key, we can then add in some code in our
// main loop so we can control what happens when the escape key is pressed
dbDisableEscapeKey ( );
// now we will set the random seed value to the timer, this will
// help us to get more random values each time we run the program
dbRandomize ( dbTimer ( ) );
// we are going to display a backdrop for the scene, to do this
// we load our image and give it an ID number of 1, this particular
// image is of a sky at night with stars
dbLoadImage ( "backdrop.bmp", 1 );
// the next step is to create a sprite that uses this image, this
// is achieved by calling dbSprite and passing in a value of 1 for the
// sprites ID, 0 for the X coordinate, 0 for the Y coordinates and a
// value of 1 for the image
dbSprite ( 1, 0, 0, 1 );
// next we will load in some animated sprites, before doing this
// we need to adjust the image color key, by using this function we
// can make a specific color be transparent, in our case we want this
// to be bright pink
dbSetImageColorKey ( 255, 0, 255 );
// in this loop we're going to create some animated sprites, the image
// we load contains frames of animation for an asteroid
for ( int i = 2; i < 30; i++ )
{
// create an animated sprite and give it the ID number from the
// variable i, next is the filename, now we come to how many frames
// across and down, in our case this is 4, finally we come to the image
// ID that the sprite will use, again we use i
dbCreateAnimatedSprite ( i, "sprite.bmp", 4, 4, i );
// position our sprite at a random location
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
// run a loop through all our sprites
for ( int i = 2; i < 30; i++ )
{
// move the sprite down and play its animation
// moving from frame 1 to 16 with a delay of 60 ms
dbMoveSprite ( i, -2 );
dbPlaySprite ( i, 1, 16, 60 );
// check the position of the sprite, if it has gone off scren
// then reposition it back to the top
if ( dbSpriteY ( i ) > 500 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
// here we check if the escape key has been pressed, when it has
// we will break out of the loop
if ( dbEscapeKey ( ) )
break;
// here we make a call to update the contents of the screen
dbSync ( );
}
// when the user presses escape the code will break out to this location
// and we can free up any previously allocated resources
// delete all the sprites
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
// delete the backdrop image
dbDeleteImage ( 1 );
// and now everything is ready to return back to Windows
return;
}