INSERT INTO `dept` VALUES (10,'部门ACCOUNTING','NEW YORK'),(20,'部门RESEARCH','DALLAS'),(30,'部门SALES','CHICAGO'),(40,'部门OPERATIONS','BOSTON ');
编译和运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
mkdir build cd build cmake .. make
ubuntu@VM-16-5-ubuntu:~/cpp_db_conn/build$ ./c_mysql_conn connect success! insert OK 查询到 6 行 deptno dname loc 10 部门ACCOUNTING NEW YORK 20 部门RESEARCH DALLAS 30 部门SALES CHICAGO 40 部门OPERATIONS BOSTON 111 research new york delete OK
cpp_mysql_conn.cpp g++ cpp_mysql_conn.cpp -o test -lmysqlcppconn
cmake编译和运行
1 2 3 4 5 6 7 8 9
mkdir build cd build cmake .. make
ubuntu@VM-16-5-ubuntu:~/cpp_db_conn/build$ ./cpp_mysql_conn Running 'SELECT 'Hello World!' AS _message'... ... MySQL replies: Hello World! ... MySQL says it again: Hello World!
cpp查询sqlite方案cpp-sqlite-conn
依赖安装包:
1
sudo apt-get install libsqlite3-dev
编译报错:
1 2
error while loading shared librariesLlibodo-sqlite-2.4.0.so:can't open shared object file:no such file or directory ldd driver
解压:odb-2.4.0.tar.gz ./configure need 01,报错configure: error: GCC plugin headers not found; consider installing GCC plugin development package 解决:sudo apt-get install gcc-5-plugin-dev 02,报错configure: error: libcutl is not found; consider using --with-libcutl=DIR 解决:libcutl:wget https://www.codesynthesis.com/download/libcutl/1.10/libcutl-1.10.0.tar.gz 安装libcutl(./confgigure,make,make install) make make install 验证:odb --version odb: error while loading shared libraries: libcutl-1.10.so: cannot open shared object file: No such file or directory sudo ln -s /usr/local/lib/libcutl-1.10.so /usr/lib/libcutl-1.10.so 验证:odb --version,ok
Common Runtime Library,libodb-2.4.0,odb的核心库
1 2
解压libodb-2.4.0.tar.gz ./configure && make && make install
解压libodb-mysql-2.4.0 ./configure configure: error: libmysqlclient_r is not found; consider using CPPFLAGS/LDFLAGS to specify its location sudo apt-get install libmysqlclient-dev -y sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient_r.so make make install
解压libodb-sqlite-2.4.0.tar.gz ./configure configure: error: libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to specify its location sudo apt-get install libsqlite3-dev make make install
Profile Libraries
1 2 3 4 5 6 7
解压libodb-boost-2.4.0 ./configure configure: error: boost is not found; consider using CPPFLAGS/LDFLAGS or --with-boost=DIR to specify its location sudo apt-get install libboost-all-dev 不确定下面还是否有必要: make make install