반응형
poco c++ ][ 설치및 hello world 찍기
ace wrapper과boost 와 함께 모던 c++라이브러리중 하나.
윈도우/리눅스/안드로이드/os x/임베디드 시스템등을 지원
"Without a good library,
most interesting tasks are hard to do in C++;
but given a good library, almost any task can be made easy."
most interesting tasks are hard to do in C++;
but given a good library, almost any task can be made easy."
- Bjarne Stroustrup
1. overview

2. 소스 다운로드

3. install ( . poco.sh )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://gist.githubusercontent.com/ox1111/17f2fb0b1a839afd4d5a641452769c90/raw/8f47f993ae611331e47a4263306c7b72ff699c06/poco.sh | |
chmod 755 | |
. poco.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt install openssl libssl-dev libiodbc2 libiodbc2-dev libpq-dev -y | |
git clone -b master https://github.com/pocoproject/poco.git | |
pushd poco | |
./configure | |
make -s -j4 | |
sudo make install | |
echo 'export LD_LIBRARY_PATH=/usr/local/lib' >> ~/.bashrc | |
. ~/.bashrc | |
4. 소스1 ( poco_helloworld.cpp )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Poco/Util/Application.h> | |
class HelloPocoApplication : public Poco::Util::Application | |
{ | |
protected: | |
virtual int main(const std::vector<std::string> &args) | |
{ | |
std::cout << "Hello, POCO C++ Libraries!" << std::endl; | |
return EXIT_OK; | |
} | |
}; | |
POCO_APP_MAIN(HelloPocoApplication); |
컴파일하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -o poco_helloworld poco_helloworld.cpp -lPocoFoundation -lPocoUtil | |
./poco_helloworld |
5. 소스2 (reference-counting.cpp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Poco/RefCountedObject.h> | |
#include <Poco/AutoPtr.h> | |
#include <iostream> | |
class MyRCO : public Poco::RefCountedObject | |
{ | |
public: | |
MyRCO() | |
{ | |
} | |
void great() const | |
{ | |
std::cout << "Hello, RCO!" << std::endl; | |
} | |
protected: | |
~MyRCO() | |
{ | |
} | |
}; | |
int main(int argc, char **argv) | |
{ | |
Poco::AutoPtr<MyRCO> pMyRCO(new MyRCO()); | |
pMyRCO->great(); | |
(*pMyRCO).great(); | |
MyRCO *p1 = pMyRCO; | |
MyRCO *p2 = pMyRCO.get(); | |
std::cout << "[Before] Reference count: " << pMyRCO->referenceCount() << std::endl; | |
{ | |
Poco::AutoPtr<MyRCO> anotherAutoPtr(pMyRCO); | |
std::cout << "[In Scope] Reference count: " << pMyRCO->referenceCount() << std::endl; | |
} | |
std::cout << "[Out Scope] Reference count: " << pMyRCO->referenceCount() << std::endl; | |
return 0; | |
} |
컴파일하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -o reference-counting reference-counting.cpp -lPocoFoundation | |
./reference-counting | |
Hello, RCO! | |
Hello, RCO! | |
[Before] Reference count: 1 | |
[In Scope] Reference count: 2 | |
[Out Scope] Reference count: 1 |
반응형