Eclipse is a Good IDE for C++.
And, CMake is a useful Makefile generation tool.
We hope that we might integrate them together.
mkdir buildeclipse
cd buildeclipse/
cmake ../SOURCE_FILES/ -G"Eclipse CDT4 - Unix Makefiles"\
-DCMAKE_ECLIPSE_VERSION=4.3\
-DCMAKE_CXX_COMPILER_ARG1=-std=c++11
Note:
If you get an error of like this:
Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
use -D_ECLIPSE_VERSION=4.3
instead of -DCMAKE_ECLIPSE_VERSION=4.3
.
PROJECT(HELLO)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Optional
# or SET(_ECLIPSE_VERSION 4.3). If you add these, you may omit `-DCMAKE_ECLIPSE_VERSION=4.3`
SET(CMAKE_ECLIPSE_VERSION 4.3)
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main pthread)
Refs:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 false
安裝BOOST: http://www.boost.org/doc/libs/1_54_0/more/getting_started/index.html
增加C++的include directory使之能找到pyconfig.h等文件。
>> export CPLUS_INCLUDE_PATH=/usr/include/python2.7/:$CPLUS_INCLUDE_PAYH
寫一個簡單的測試程序:
>> cat hello.cpp
#include <iostream> using namespace std; void say_hello(const char* name) { cout << "Hello " << name << "!\n"; } int main(){return 0;} #include <boost/python/module.hpp> #include <boost/python/def.hpp> using namespace boost::python; BOOST_PYTHON_MODULE(hello) { def("say_hello", say_hello); }
編譯:
>> g++ hello.cpp -lboost_python -lpython2.7 -shared -fPIC -o hello.so
>> ls
出現有hello.so
python中的用法:
>> python Python 2.7.3 (default, Apr 10 2013, 06:20:15) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import hello >>> hello.say_hello('Bill') Hello Bill! >>>