I am an amateur VC++ developer.
I want to use CoolProp (http://www.coolprop.org/) in my academic VC++ project as a static library in a win 32 app using a VS2010 Ultimate running in x64 laptop machine.
So i have downloaded ,
1.CoolProp.lib from http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.2/static_library/ 2.CoolProp.h from http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/
and placed both in a system folder.
Next i created a sample win32 console application in VS2010 as empty sln. Added CoolProp.h as an Additional Include Directories in Properties->C/C++->General(Also copied all the dependent header files) Added CoolProp.lib as an Additional Dependencies in Properties->Linker->Input->Additional Dependencies
Then i copied this program from http://www.coolprop.org/coolprop/HighLevelAPI.html#high-level-api
#include "CoolProp.h"
#include <iostream>
using namespace CoolProp;
int main()
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
std::vector<double> z(2,0.5);
// Second type (C++ only, a bit faster)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane&Ethane", z) << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane&Ethane", z) << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane&Ethane", z) << std::endl;
return EXIT_SUCCESS;
}
and tried to build.
Build(but compiled perfectly) failed due to
main.obj : error LNK2019: unresolved external symbol "double __cdecl PropsSI(char,char,double,char,double,char *)" (?Props@@YANDDNDNPAD@Z) referenced in function _main
Can somebody please help me in resolving this ? I already read below posts from stackoverflow , but couldnt solve please help
It is working for me, (VS 2010) as following:
-add file 'CoolPropLib.h' to your project, by right click on header files folder in solution explorer -> Add -> Existing Item -> choose 'CoolPropLib.h'.
-open file 'CoolPropLib.h' and comment line 22 as follow (//#include "PlatformDetermination.h").
- add these two lines (23, 24) :
#define CONVENTION __stdcall
#define EXTERNC
-use library that is built with __stcall not that built with __cdecel :
http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/Windows/32bit__stdcall_calling_convention/CoolProp.lib/download
-you will need the dll (for __stdcall) from :
http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/Windows/32bit__stdcall_calling_convention/CoolProp.dll/download
-create folder named 'lib' in your project folder in windows explorer (not in VS) and put 'CoolProp.lib' in it.
-in Properties->Linker->General-> Additional libraries Directories, add $(ProjectDir)\lib
-the code I test is:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include "CoolPropLib.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
return 0;
}
-if you have problems, I can upload the project to you.
EDIT 1: