<p> 初歩的なんだろうけど、ものすごく失敗したのでメモ</p>
<p>ソケットプログラムをC言語レベルでも調査するため、WSL2の整備をした。1</p>
<p>まずはインストール ちょっとダブっているかも</p>
<pre class="wp-block-preformatted">sudo apt update
sudo apt upgrade -y
sudo apt install build-essential -y
sudo apt install gdb
sudo apt-get install -y make build-essential llvm libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev net-tools wget curl
sudo apt install -y language-pack-ja-base language-pack-ja</pre>
<p> さて、では以下のサンプルコードとしてを作成しいざコンパイル</p>
<p></p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include <iostream>
int main ( void ) {
return 0;
}</pre>
<p>いつものgccだ、あれこんな風にコンパイルできない! なぜだ??</p>
<pre class="wp-block-preformatted">$ gcc test.cpp
/usr/bin/ld: /tmp/cclY8l7J.o: in function <code>__static_initialization_and_destruction_0(int, int)': test22.cpp:(.text+0x38): undefined reference to</code>std::ios_base::Init::Init()'
/usr/bin/ld: test22.cpp:(.text+0x4d): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
</pre>
<h2 class="wp-block-heading">正しくは!</h2>
<pre class="wp-block-preformatted">$ g++ test.cpp</pre>
<p>これだけのことだったのか。まだまだ力不足、お恥ずかしい。。</p>
初歩的なんだろうけど、ものすごく失敗したのでメモ
ソケットプログラムをC言語レベルでも調査するため、WSL2の整備をした。1
まずはインストール ちょっとダブっているかも
sudo apt update
sudo apt upgrade -y
sudo apt install build-essential -y
sudo apt install gdb
sudo apt-get install -y make build-essential llvm libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev net-tools wget curl
sudo apt install -y language-pack-ja-base language-pack-ja
さて、では以下のサンプルコードとしてを作成しいざコンパイル
#include <iostream>
int main ( void ) {
return 0;
}
いつものgccだ、あれこんな風にコンパイルできない! なぜだ??
$ gcc test.cpp
/usr/bin/ld: /tmp/cclY8l7J.o: in function __static_initialization_and_destruction_0(int, int)': test22.cpp:(.text+0x38): undefined reference to
std::ios_base::Init::Init()'
/usr/bin/ld: test22.cpp:(.text+0x4d): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
正しくは!
$ g++ test.cpp
これだけのことだったのか。まだまだ力不足、お恥ずかしい。。
ライセンス:本記事のテキスト/コードは特記なき限り
CC BY 4.0 です。引用の際は出典URL(本ページ)を明記してください。
利用ポリシー もご参照ください。
コメント