我在Mac上寫C+代碼。為什么編譯時會出現此錯誤?:架構i 386的未定義符號:“log:the String”,引用于libTest.a(Log.o)ld中的log:方法(std:string):i 386 clang:Error:linker命令失敗,退出代碼1(使用-v查看調用)不確定我的代碼是否錯了,或者我必須向Xcode添加額外的標志。我當前的XCode配置是“靜態庫”項目的默認配置。我的代碼:羅格#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; }我從測試代碼中調用‘Method’,以這樣的方式:‘log:Method(“ASD”):’謝謝你的幫助。
- 2 回答
- 0 關注
- 466 瀏覽
添加回答
舉報
0/150
提交
取消