Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to link subproject library into the executeable in Visual Studio

Posted on 2014-01-26
Medium Priority
Last Modified: 2014-01-26
I have a project that I create a number of subprojects in Visual Studio c++ 2013.  I have defined the project dependency and build order.  However I still have unresolved external reference.  What can be a problem.  What else should I check.

Question by:tommym121
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
LVL 86

Expert Comment

ID: 39810317
What exactly does the error message look like?

Author Comment

ID: 39810325
appmain.obj : error LNK2019: unresolved external symbol "public: __thiscall configSettings::configSettings(void)" (??0configSettings@@QAE@XZ) referenced in function _wmain
9>appmain.obj : error LNK2019: unresolved external symbol "public: void __thiscall configSettings::load(char const *)" (?load@configSettings@@QAEXPBD@Z) referenced in function _wmain
9>appmain.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall configSettings::DataServer_IP(void)" (?DataServer_IP@configSettings@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _wmain
9>appmain.obj : error LNK2019: unresolved external symbol "public: int __thiscall configSettings::DataServer_Port(void)" (?DataServer_Port@configSettings@@QAEHXZ) referenced in function _wmain

Author Comment

ID: 39810329
And this is my configSettings class

class configSettings

      std::string m_logLevel;      // log level Config.level
      bool m_logToConsole;         // log to console Config.logToConsole
      bool m_logToFile;                   // log to file Config.logToFile
      std::string m_DataServerIP;  // Data Server IP address Config.dataServerIP
      std::string m_logPath;             // Log directory/Path Config.LogPath
      int m_DataServerPort;             // DataServer Port number Config.dataServerPort
      void load(const std::string &filename);      
      void load(const char *filename);
      void save(const std::string &filename);

      int LogLevel();
      bool LogToFile();
      bool LogToConsole();
      std::string DataServer_IP();
      int DataServer_Port();

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 86

Expert Comment

ID: 39810336
Ah, OK, so name mangling can be ruled out. Is your 'configSettings' class within a static library or a DLL? If the latter applies, are you exporting it correctly and using the import library?

Author Comment

ID: 39810341
Please see the atttachment.
LVL 86

Expert Comment

ID: 39810350
OK. How are you linking that library to executable? Did you add that 'configSettings.lib' as 'Additional Library' in the app's settings? Also, did you do that for both the 'Debug' and 'Release' configuration?

Author Comment

ID: 39810379
not working.  I have set Link Depenedency Yes

Author Comment

ID: 39810381
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 39810392
Well, Setting 'Yes' isn't really enough, you need to specify the lib by name. Assuming that 'Additional Library Directories' contains the path where 'configSettings.lib' resides, try adding

#pragma comment(lib, "configSettings.lib")

Open in new window


Author Closing Comment

ID: 39810562
Thanks.  It works.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question