Solved

How to link subproject library into the executeable in Visual Studio

Posted on 2014-01-26
10
431 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Lambda for random numbers problem 7 117
Exception thrown at 0x00007FFD5BC81F28 7 50
Why  my code (program) build with old compiler? 11 79
learn programming 8 42
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

830 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