私はMacにC++コードを書いています。私のコードが間違っているか、私はXcodeのに追加のフラグを追加する必要があればわからない静的変数リンクエラー
Undefined symbols for architecture i386: "Log::theString", referenced from: Log::method(std::string) in libTest.a(Log.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
を?:コンパイルするとき、私はこのエラーが出るのはなぜ。私の現在のXCode設定は、 'スタティックライブラリ'プロジェクトのデフォルト設定です。
マイコード:
LOG.H ------------
#include <iostream>
#include <string>
using namespace std;
class Log{
public:
static void method(string arg);
private:
static string theString ;
};
Log.cpp ----
#include "Log.h"
#include <ostream>
void Log::method(string arg){
theString = "hola";
cout << theString << endl;
}
私はこの方法でテストコードから 'メソッド'を呼び出します。 'Log :: method( "asd"):'
ありがとうございます。
に
を含めます。参照される他の質問は本質的に非常に一般的で、私のMac特有の問題を解決するのには役に立たなかったでしょう。 – Adam