ここには単純なC++プログラムがあり、動作するはずです。私のコードはここからの参照です。 Convert command line argument to string文字列を含むときにコンパイルできない
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
//using namespace std;
int main(int argc, char *argv[]){
std::string boss;
//printf("PROGRAM NAME: %s\n", argv[0]);
if (argc > 1){
//printf("%s\n",&argv[1][0]);
printf("%s\n",argv[1]);
boss = argv[1];
}
}
コンパイルが、それは問題が出てくるとき:
/tmp/cctYLBpB.o:機能でmain': testarg.cpp:(.text+0x1c): undefined reference to
のstd ::のbasic_string、STD ::アロケータ> ::のbasic_string()」 testarg。 cpp :(。テキスト+ 0x58):未定義参照std::string::operator=(char const*)' testarg.cpp:(.text+0x64): undefined reference to
std :: basic_string、std :: allocator :: :: basic_string() ' testarg.cpp :(。テキスト+ 0x78):未定義参照std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' testarg.cpp:(.text+0x7c): undefined reference to
__cxa_end_cleanup' /tmp/cctYLBpB.o:関数__static_initialization_and_destruction_0(int, int)': testarg.cpp:(.text+0xc0): undefined reference to
std :: ios_base :: Init :: Init() ' testa rg.cpp :(テキスト+ 0xe4):未定義の参照std::ios_base::Init::~Init()' /tmp/cctYLBpB.o:(.ARM.extab+0x0): undefined reference to
__gxx_personality_v0' に collect2は:エラー:ldが返さ1つの終了ステータス
は君たちの専門家をやって上の任意の問題を見ていましたか?私は考えていません...
プログラムの作成に使用したコマンドは何ですか? –
私がコンパイルするコマンドはgcc "filename"です.cpp -o testc –
コンパイル/ビルドには 'g ++'を使います。 –