gcc 编译多线程文件和含MySql数据库操作文件
gcc 强大的编译器就不作介绍了
linux下用gcc命令编译多线程C程序文件和含有MySql数据库操作文件
1.编译多线程文件
gcc -o mylti_thread.o multi_thread.c -lpthread
其中的multi_thread.c表示源文件,mylti_thread.o表示编译产生的目标文件,-lpthread表示引入多线程库,在《Using the GNU Compiler Collection》gcc 4.30 中关于-lpthread的描述如下:
-lpthread Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. It does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it. These are HP-UX specific flags. 要不然会出现类似以下错误
/tmp/cc20DpmC.o: In function `main':
multi_thread.c:(.text+0x78): undefined reference to `pthread_create'
multi_thread.c:(.text+0xe2): undefined reference to `pthread_create'
multi_thread.c:(.text+0xf6): undefined reference to `pthread_join'
multi_thread.c:(.text+0x10a): undefined reference to `pthread_join'
2.编译MySql数据库操作文件
gcc -o sqltest.o sqltest.c -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient
或者gcc -o sqltest $(mysql_config --cflags) sqltest.c $(mysql_config --libs)
参见网址 http://blog.163.com/zhangjinqing1234@126/blog/static/30730260200992251411161/
其中的sqltest.c表示源文件,sqltest.o表示编译产生的目标文件,-I表示指定头文件的默认搜索路径,-L表示指定要链接的库,同上面-l,具体可参见网址
http://blog.csdn.net/zhulinfeiba/archive/2009/08/20/4464727.aspx
-I后面的参数/usr/include/mysql可能会因为MySql安装的路径不同而有所改变,在终端输入:whereis mysql,结果如下:
mysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/include/mysql
/usr/share/mysql /usr/share/man/man1/mysql.1.gz
再cd /usr/include/mysql
,然后 ls
decimal.h my_dir.h mysqld_error.h sql_common.h
errmsg.h my_getopt.h mysql_embed.h &n
相关文档:
一、事务处理(myisam引擎不支持事务,innodb引擎支持事务)
(1)start transaction
(2)commit
(3)rollback,rollback to [savepoint name]
(4)savepoint [savepoint name]
(5)set autocommit=0 or 1
(6)release savepoint [savepoint name]
注意:create、drop等操作,不能回退
二、字符集
1.字符编码 ......
今天搞了一下午,在电脑上搭建了APM平台
系统:Windows7 Professional EN
Apache2.2.9:http://archive.apache.org/dist/httpd/binaries/win32/apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi
PHP5.3.1:http://windows.php.net/downloads/releases/php-5.3.1-Win32-VC6-x86.zip
MySQL5.1.42:http://ftp.iij.ad.jp/pub/db/ ......
今天读到
When should you store serialized objects in the database?
,
其中针对
FriendFeed使用Mysql来存储
作为引题,
建议在考虑此方案时一定要三思。为什么?参考这里
Kiss KISS KISS
. 其实
Schema-Less没有错,但不能什么场景都上此方案,要
分析利弊,减少不必要的应用层复杂度。
文中提到的Serializ ......
数值类型
MySQL 的数值数据类型可以大致划分为两个类别,一个是整数,另一个是浮点数或小数。许多不同的子类型对这些类别中的每一个都是可用的,每个子类型支持不同大小的数据,并且 MySQL 允许我们指定数值字段中的值是否有正负之分或者用零填补。
表列出了各种数值类型以及它们的允许范围和占用的内存空间。
......