Solved

How to link subproject library into the executeable in Visual Studio

Posted on 2014-01-26
10
427 Views
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.

Thanks.
0
Comment
Question by:tommym121
  • 6
  • 4
10 Comments
 
LVL 86

Expert Comment

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

Author Comment

by:tommym121
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
0
 

Author Comment

by:tommym121
ID: 39810329
And this is my configSettings class

class configSettings
{

private:
      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
public:
      configSettings();
      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();


};
0
 
LVL 86

Expert Comment

by:jkr
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?
0
 

Author Comment

by:tommym121
ID: 39810341
Please see the atttachment.
Capture.JPG
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:jkr
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?
0
 

Author Comment

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

Author Comment

by:tommym121
ID: 39810381
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 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

0
 

Author Closing Comment

by:tommym121
ID: 39810562
Thanks.  It works.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 clear a vector as well as how to detect empty vectors in C++.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now