Skip to content

Instantly share code, notes, and snippets.

@akirakiron
Last active December 12, 2015 06:28
Show Gist options
  • Save akirakiron/4729600 to your computer and use it in GitHub Desktop.
Save akirakiron/4729600 to your computer and use it in GitHub Desktop.
C++で静的ライブラリをリンクする時の引数の順番で詰まったのでメモ. ライブラリ間に依存関係がある場合には,依存している方を前に,依存されている方を後に置く. そうしないと'undefined reference'エラーになる. arコマンドで一つのライブラリにまとめる際は,引数の順番は気にする必要はない.
int get_zero();
int get_one() {
return get_zero() + 1;
}
#include <iostream>
int get_one();
int main() {
std::cout << get_one() << std::endl;
return 0;
}
int get_zero() {
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment