Sign in to follow this  

Lnk errors

This topic is 2327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[code]

1>------ Build started: Project: MyGame, Configuration: Debug Win32 ------
1> Audio.cpp
1> Game.cpp
1> Generating Code...
1> Compiling...
1> Timer.cpp
1> main.cpp
1> Generating Code...
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Game.obj : error LNK2019: unresolved external symbol "public: __thiscall Audio::~Audio(void)" (??1Audio@@QAE@XZ) referenced in function __unwindfunclet$??0Game@@QAE@PAUEnvironment@@@Z$0
1>Game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Audio::PlayMusic(struct _Mix_Music *,int)" (?PlayMusic@Audio@@QAEXPAU_Mix_Music@@H@Z) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
1>Game.obj : error LNK2019: unresolved external symbol "public: struct _Mix_Music * __thiscall Audio::LoadMusic(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadMusic@Audio@@QAEPAU_Mix_Music@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
1>Game.obj : error LNK2019: unresolved external symbol "public: __thiscall Audio::Audio(void)" (??0Audio@@QAE@XZ) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
1>C:\Users\david\Documents\Visual Studio 2010\Projects\MyGame\Debug\MyGame.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/code]


Could you guys please tell me how to fix these and how to read them so i could do it myself next time?

Share this post


Link to post
Share on other sites
It's complaining that it can't find the audi library that you're trying to use in certain places. Without more info of what libraries you're using it's a bit hard to give a proper answer, but the solution is to add them to the additional dependencies list in your project properties.

Give us more information regarding what libraries you're using and we can give a more detailed answer.

Share this post


Link to post
Share on other sites
[quote name='nano511' timestamp='1312567970' post='4845120']
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
[/quote]

This means you are mixing visual studio's standard runtime libraries.

You might be mixing debug and non-debug, or single-threaded with multithreaded.

If you are linking with external libraries, such as a pre-build SDL package, you need to make sure that those libraries were built with the same options. Check the documentation for the package to see what options it was built with. Or better yet, build it yourself as a sub-project so you know it has the same build settings.

[quote]
1>Game.obj : error LNK2019: unresolved external symbol "public: __thiscall Audio::~Audio(void)" (??1Audio@@QAE@XZ) referenced in function __unwindfunclet$??0Game@@QAE@PAUEnvironment@@@Z$0
1>Game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Audio::PlayMusic(struct _Mix_Music *,int)" (?PlayMusic@Audio@@QAEXPAU_Mix_Music@@H@Z) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
1>Game.obj : error LNK2019: unresolved external symbol "public: struct _Mix_Music * __thiscall Audio::LoadMusic(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadMusic@Audio@@QAEPAU_Mix_Music@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
1>Game.obj : error LNK2019: unresolved external symbol "public: __thiscall Audio::Audio(void)" (??0Audio@@QAE@XZ) referenced in function "public: __thiscall Game::Game(struct Environment *)" (??0Game@@QAE@PAUEnvironment@@@Z)
[/quote]

You included headers for your Audio class, but didn't include the rest.

It is looking for the implementation of:

Audio::Audio
Audio::~Audio
Audio::PlayMusic
Audio::LoadMusic

You probably need to add to your project either the .cpp file or the .lib file that contains the implementation.

Sometimes when you add your own class it will only add it to a release or debug build, make sure it gets added to both.

If you are adding an external library, make sure you add the library to all configurations. In Visual Studio, open the project property pages, then pick "All configurations", then in the libraries under "Additional Dependencies" add your libraries. I'd also check the documentation for whatever tools you are trying to add to make sure you add them the way it expects. Some libraries require other settings to be set, or different settings for debug and release builds.

Share this post


Link to post
Share on other sites

This topic is 2327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this