追加のインクルードライブラリにはtwitcurl.hが入っているディレクトリを指定し、twitcurl.libはカレントディレクトリ内に置いています。
実行すると、以下のようなエラーが出ます。
LNK2038 '_MSC_VER' の不一致が検出されました。値 '1600' が 1900 の値 'Source.obj' と一致しません。
LNK2001 外部シンボル ""__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)" は未解決です。
のようなエラーが多量に出ます。
どこがおかしいのでしょうか。
使用コンパイラはVisualStudio2017でOSはWindows10です
#include <iostream>
#include <string>
#include <twitcurl.h>
#pragma comment(lib,"twitcurl.lib")
using namespace std;
/*
* [CLASS] Process
*/
class Proc
{
twitCurl twitterObj;
string strConsumerKey, strConsumerSecret;
string strAccessTokenKey, strAccessTokenSecret;
string strReplyMsg;
public:
Proc(); // Constructor
bool execMain(string); // Main Process
};
/*
* Proc - Constructor
*/
Proc::Proc()
{
// Initialize
strConsumerKey = "あえて空白";
strConsumerSecret = "あえて空白";
strAccessTokenKey = "あえて空白";
strAccessTokenSecret = "あえて空白";
}
/*
* Main Process
*/
bool Proc::execMain(string strString)
{
try {
// Set Twitter consumer key and secret,
// OAuth access token key and secret
twitterObj.getOAuth().setConsumerKey(strConsumerKey);
twitterObj.getOAuth().setConsumerSecret(strConsumerSecret);
twitterObj.getOAuth().setOAuthTokenKey(strAccessTokenKey);
twitterObj.getOAuth().setOAuthTokenSecret(strAccessTokenSecret);
// Verify account credentials
if (!twitterObj.accountVerifyCredGet()) {
twitterObj.getLastCurlError(strReplyMsg);
cout << "\ntwitCurl::accountVerifyCredGet error:\n"
<< strReplyMsg.c_str() << endl;
return false;
}
// Post a message
strReplyMsg = "";
if (!twitterObj.statusUpdate(strString)) {
twitterObj.getLastCurlError(strReplyMsg);
cout << "\ntwitCurl::statusUpdate error:\n"
<< strReplyMsg.c_str() << endl;
return false;
}
}
catch (char *e) {
cout << "[EXCEPTION] " << e << endl;
return false;
}
return true;
}
/*
* Execution
*/
int main(int argc, char* argv[]) {
try {
if (argc != 2) {
cout << "Usage: ./Twitcurl sentence" << endl;
return true;
}
Proc objMain;
bool bRet = objMain.execMain(argv[1]);
if (!bRet) cout << "ERROR!" << endl;
}
catch (char *e) {
cout << "[EXCEPTION] " << e << endl;
return 1;
}
return 0;
}