「Color.cppとColor.hpp ncursesライブラリ」を静的ライブラリにしてそれをMain.cppで使いたいのですが以下の実行してコマンド部まではうまく行くのですがエラー部のようにMain.cppをコンパイルするが出来ず参考サイトように.oファイルと一緒にビルド出来ません。
これはどうやるのでしょうか?
やりたいこと
「Color.hpp Color.cpp ncursesライブラリ」という静的ライブラリを生成して
それをMain.cppで使いたい
参考サイト: https://www.yunabe.jp/docs/static_library.html
エラー
Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ g++ Main.cpp /usr/bin/ld: /tmp/cc9IT7mN.o: in function `main': Main.cpp:(.text+0x8): undefined reference to `init_colorpairs()' collect2: error: ld returned 1 exit status Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ g++ Main.cpp -ltest.a /usr/bin/ld: -ltest.a が見つかりません collect2: error: ld returned 1 exit status Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ g++ Main.cpp test.a /usr/bin/ld: test.a(Color.o): in function `init_colorpairs()': Color.cpp:(.text+0x68): undefined reference to `init_pair' /usr/bin/ld: test.a(Color.o): in function `setcolor(int, int)': Color.cpp:(.text+0x1cc): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x1d0): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x1f8): undefined reference to `wattr_on' /usr/bin/ld: Color.cpp:(.text+0x218): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x21c): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x22c): undefined reference to `wattr_on' /usr/bin/ld: test.a(Color.o): in function `unsetcolor(int, int)': Color.cpp:(.text+0x254): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x258): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x280): undefined reference to `wattr_off' /usr/bin/ld: Color.cpp:(.text+0x2a0): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x2a4): undefined reference to `stdscr' /usr/bin/ld: Color.cpp:(.text+0x2b4): undefined reference to `wattr_off' collect2: error: ld returned 1 exit status Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $
実行したコマンド
Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ g++ -c Color.cpp Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ ar rcs test.a Color.o Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $
tree
Shigurechan@Shigurechan:~/Project/ConsoleGame/lib $ tree . ├── Color.cpp ├── Color.cpp~ ├── Color.hpp ├── Color.o ├── Main.cpp ├── Main.cpp~ └── test.a
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。