Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to link subproject library into the executeable in Visual Studio

Posted on 2014-01-26
10
Medium Priority
?
453 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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 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

0
 

Author Closing Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

824 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