본문 바로가기
C++/0x04-poco

poco c++ ][ 설치및 hello world 찍기

by SpeeDr00t 2016. 8. 4.
반응형

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."
 
- Bjarne Stroustrup
 

1. overview

 

 

2. 소스 다운로드

 

3. install ( . poco.sh )

wget https://gist.githubusercontent.com/ox1111/17f2fb0b1a839afd4d5a641452769c90/raw/8f47f993ae611331e47a4263306c7b72ff699c06/poco.sh
chmod 755
. poco.sh
view raw insall_poco.sh hosted with ❤ by GitHub
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
view raw poco.sh hosted with ❤ by GitHub

4. 소스1 ( poco_helloworld.cpp )

#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);

 

컴파일하기

g++ -o poco_helloworld poco_helloworld.cpp -lPocoFoundation -lPocoUtil
./poco_helloworld
view raw compile.sh hosted with ❤ by GitHub


5. 소스2 (reference-counting.cpp)

#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;
}

 

컴파일하기

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
view raw result1.sh hosted with ❤ by GitHub

 

반응형