
POCOをLinuxで使えるようにして見たいと思います。
環境
- Ubuntu 18.04
ビルドする
公式サイトを参考にインストールします。
ソースコードはGithubからダウンロードしてきました。
まずは、open-sslを入れる必要があるようです。
$ sudo apt-get install openssl libssl-dev |
とりあえずmakeしてみます。
$ . /configure $ make |
エラーになった...
: sh: 1: g++: not found : Makefile:134: recipe for target 'Foundation-libexec' failed make : *** [Foundation-libexec] Error 2 |
build-essentialを入れる必要があるようだ...
$ sudo apt-get install build-essential |
再度make... エラーになった...
/usr/bin/x86_64-linux-gnu-ld : cannot find -lz collect2: error: ld returned 1 exit status /home/kazuya/develop/poco/build/rules/exec :53: recipe for target '/home/kazuya/develop/poco/Crypto/testsuite/bin/Linux/x86_64/testrunnerd' failed make [1]: *** [ /home/kazuya/develop/poco/Crypto/testsuite/bin/Linux/x86_64/testrunnerd ] Error 1 make [1]: Leaving directory '/home/kazuya/develop/poco/Crypto/testsuite' Makefile:221: recipe for target 'Crypto-tests' failed make : *** [Crypto-tests] Error 2 $ sudo apt-get install libgl1 -> 多分これは違う $ sudo apt install libyaml-dev |
うーん
cmakeでビルドするのが推奨みたいなので、cmakeで試してみる。
$ mkdir cmake_build $ cd cmake_build $ cmake .. $ make |
Buildできた!!
$ sudo make install |
成功!
使ってみる ライブラリを更新しておく(これが必要なのかよくわからんが...)
$ sudo ldconfig |
テスト用のソースは以下の通り、Thredを使ってみる。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <Poco/Thread.h> #include <Poco/Runnable.h> #include <iostream> class HelloRunnable: public Poco::Runnable { virtual void run() { std::cout << "Hello, World!" << std::endl; } }; int main( int argc, char ** argv) { HelloRunnable runnable; Poco::Thread thread ; thread .start(runnable); thread .join(); return 0; } |
g++でビルドしてみます。
$ g++ -lPocoFoundation ThreadSample.cpp |
リンクエラー...
どうやら、インクルードパスが必要のようです。
$g++ -o ThreadSample ThreadSample.cpp -I /usr/include/C ++ /7/ -lPocoFoundation |
今度はビルドできました。
これで、POCOを使う準備ができました。
0 件のコメント :
コメントを投稿