Jump to content
  • Advertisement
Sign in to follow this  
PRO_Muffy

VS2005 - using multiple projects and linker errors

This topic is 3646 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

Hi all! I have a solution in Visual Studio 2005 with 4 projects. I've set up the dependencies in the configuration manager so that any projects relying on other projects get compiled last. I've also set up a working directory for all the projects (which is the same). However, this is the first time that I've tried adding multiple projects like this. Project A has a single file called Main.cpp in it which has the program main entry point. Project B has a number of maths library files in it. Previously Main.cpp lived in Project B but I moved it and changed all the #include headers to correspond with its new location. Project A is set to be the startup project. Previously the code compiled and ran correctly. LNK2019 definition here http://msdn.microsoft.com/en-us/library/799kze2z(VS.80).aspx states that something defined before the main entry point cannot be found despite it being declared (and used). I'm guessing it's compiling the files correctly but can't find them during linkage, which is why I'm getting the errors in Main.obj. Ignore the sampleshader.fx compile error for now. I can fix that. Can anyone provide any insight as to the link error? The message that I receive is as below: ------ Build started: Project: PiMathLib, Configuration: Debug_DirecX9 Win32 ------ Linking... MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\Debug_DirecX9\PiMathLib.exe : fatal error LNK1120: 1 unresolved externals Build log was saved at "file://c:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\PiMathLib\Debug_DirecX9\BuildLog.htm" PiMathLib - 2 error(s), 0 warning(s) ------ Build started: Project: PiRenderer, Configuration: Debug Win32 ------ Performing Custom Build Step Microsoft (R) D3D10 Shader Compiler 9.19.949.2187 Copyright (C) Microsoft Corporation 2002-2007. All rights reserved. failed to open file: c:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\PiRenderer\SampleShader.fx compilation failed; no code produced Build log was saved at "file://c:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\PiRenderer\Debug\BuildLog.htm" PiRenderer - 0 error(s), 0 warning(s) ------ Build started: Project: PilotDX9, Configuration: Debug Win32 ------ Linking... Main.obj : error LNK2019: unresolved external symbol "public: __thiscall PiMaths::PiVector3::PiVector3(float,float,float)" (??0PiVector3@PiMaths@@QAE@MMM@Z) referenced in function "bool __cdecl TestMatrix22(void)" (?TestMatrix22@@YA_NXZ) Main.obj : error LNK2019: unresolved external symbol "public: class PiMaths::PiVector3 __thiscall PiMaths::PiVector3::operator-(class PiMaths::PiVector3 &)" (??GPiVector3@PiMaths@@QAE?AV01@AAV01@@Z) referenced in function "public: bool __thiscall PiPrims::PiSphere::IsPointInside(class PiMaths::PiVector3 &)" (?IsPointInside@PiSphere@PiPrims@@QAE_NAAVPiVector3@PiMaths@@@Z) Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall PiPrims::PiCylinder::IsPointInside(class PiMaths::PiVector3 &)" (?IsPointInside@PiCylinder@PiPrims@@QAE_NAAVPiVector3@PiMaths@@@Z) referenced in function "bool __cdecl TestCylinder(void)" (?TestCylinder@@YA_NXZ) C:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\Debug\PilotDX9.exe : fatal error LNK1120: 3 unresolved externals Build log was saved at "file://c:\Documents and Settings\Gareth\My Documents\Visual Studio 2005\Projects\Pilot\PilotDX9\Debug\BuildLog.htm" PilotDX9 - 4 error(s), 0 warning(s) ========== Build: 1 succeeded, 2 failed, 1 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Advertisement
It looks like your math library is compiling to an .exe. Since the main() function is no in your math library you are getting a linker error. Change your math library to compile to a static library. You can change this through the project's properties.

Share this post


Link to post
Share on other sites
Thanks. I'll give that a go tonight when I have time (2 mins before work now!) Will let you know if it works and post what I did if it does.

[EDIT] Yeah, a silly mistake. In my solution I have a number of projects. By right clicking on a project and selecting Properties->Configuration Properties->General you can change whether a project compiles as an EXE, a DLL or a LIB. Generally you will only want one project to compile as an EXE and that project will have your main entry point (WINMAIN or main() function). The order that projects build in is important because one project may rely on files from another project. Any projects that are being relied on would normally be compiled as a DLL or LIB. I guess it would be up to you as to which is more appropriate for your application.

[Edited by - PRO_Muffy on July 5, 2008 5:12:09 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!