2010年3月23日星期二

Begin Linux OpenGL programming


  • Compiling an OpenGL/GLUT program requires you to use a number of libraries.

    • GLUT (library "glut" on Linux)
    • OpenGL (library "GL" on Linux)
    • GL Utilities (library "GLU" on Linux)
    • Windowing specific libraries needed by GLUT. For X-Windows, these include:

      • X11
      • Xmu
      • Xi

    • Often you'll also need the math library (library "m" on Linux)
    • You need to include (more) libraries if you encounter error messages such as:

      • /tmp/ccKfrBZc.o(.text+0x1a6): In function `main':

        : undefined reference to `glutInitDisplayMode'




  • Including libraries is easy with gcc or g++, just at "-l< lib-name >" to the command line.


  • So, a compilation including all these libraries would look like:

    • gcc -o myProg myProg.c -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
    • The "-o myProg" tells gcc to call the executable "myProg"
    • After compilation, you can run by typing "./myProg" or if "." is in your path just "myProg" will work.


  • On many machines, gcc doesn't know where to find the correct include
    files (those you added to your code using #include"...")

    • Adding "-I < include-path >" tells gcc where to find additional include files.
    • You'll need to add -I commands to eliminate errors such as:

      • myProg.c:1:17: Xm.h: No such file or directory




  • Often (including on the lab machines), the linker doesn't know where to find
    some of the libraries if they're stored in unusual locations (like outside of /usr/lib)

    • Adding "-L < library-path >" tells the linker where to find additional library files.
    • You'll need to add -L commands to eliminate errors such as:

      • /usr/bin/ld: cannot find -lX11




Suggested Command Line to Compile on Lab Machines:




gcc -o myProg myProg.c -I /usr/X11R6/include/ -L /usr/X11R6/lib64/ -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm


You should just be able to copy/paste. The only changes you need to make are:


  • Change the filename "myProg.c" to the filename of your program

    • (If you have more than one C file, include more than one on the command line)

  • Change "gcc" to "g++" if you're using C++.




NOTE: If you are compiling at home, you may need to change /usr/X11R6/lib64 to
/usr/X11R6/lib. It turns out the lab machines in MLH 301 have both 32- and 64-bit versions
of OpenGL and GLU, but only a 64-bit version of GLUT.





Chris Wyman (cwyman@cs.uiowa.edu)

2010年3月2日星期二

Linux硬件信息查询汇总一览

注:以下实用工具大部分是GNU工具集,适用于GNU/Linux,其他Unix衍生发行版可能不自带(可能需要自己手动编译)。

--------------------------------------------------
1, 主板信息-查看主板的序列号
--------------------------------------------------
#使用命令
dmidecode | grep -i 'serial number'
#查看板卡信息
cat /proc/pci
--------------------------------------------------
2, cpu信息
--------------------------------------------------
#通过/proc文件系统
1) cat /proc/cpuinfo
#通过查看开机信息
2) dmesg | grep -i 'cpu'
#
3)dmidecode -t processor
--------------------------------------------------
3, 硬盘信息
--------------------------------------------------
#查看分区情况
fdisk -l
#查看大小情况
df -h
#查看使用情况
du -h
#
hdparm -I /dev/sda
#
dmesg | grep sda
查看IDE硬盘信息:sudo hdparm -i /dev/hda
查看SATA硬盘信息 :sudo hdparm -I /dev/sda 或 sudo blktool /dev/sda id
--------------------------------------------------
4, 内存信息
--------------------------------------------------
1) cat /proc/meminfo
2) dmesg | grep mem
3) free -m
4) vmstat #Report virtual memory statistics
5) dmidecode | grep -i mem
--------------------------------------------------
5, 网卡信息
--------------------------------------------------
1) dmesg | grep -i 'eth'
2) cat /etc/sysconfig/hwconf | grep -i eth
3) lspci | grep -i 'eth'
--------------------------------------------------
6, 鼠标键盘和USB信息
--------------------------------------------------
查看键盘和鼠标:cat /proc/bus/input/devices
查看USB设备:cat /proc/bus/usb/devices
查看各设备的中断请求(IRQ):cat /proc/interrupts
--------------------------------------------------
7, 显卡信息
--------------------------------------------------
1)lspci |grep -i 'VGA'
2)dmesg | grep -i 'VGA'
--------------------------------------------------
8, 声卡信息
--------------------------------------------------
1)lspci |grep -i 'VGA'
2)dmesg | grep -i 'VGA'
--------------------------------------------------
7, 其他命令
--------------------------------------------------
用硬件检测程序kuduz探测新硬件:service kudzu start ( or restart)
dmesg (查看所有启动时检测到的硬件信息)
lspci (显示外设信息, 如usb,网卡等信息)
cat /etc/sysconfig/hwconf
mpstat
查看PCI设备:lspci
查看USB设备:lsusb -v
查看网卡状态:sudo ethtool eth0
查看CPU信息:cat /proc/cpuinfo
显示当前硬件信息:sudo lshw
--------------------------------------------------
8, 需要手动安装的工具
--------------------------------------------------
lshw,hwinfo,hal-device-manager

2010年2月25日星期四

两部Linux及自由软件纪录片



中文:代码
英文:The Code - Linux
原名:Koodi - Linuxin tarina (Finland)
发行:2001年
导演:HANNU PUTTONEN
主演:Linus Torvalds / Eric Raymond / Richard M. Stallman / David S. Miller / Alan Cox
语言:英语
内容介绍:1991 年,年仅 20岁的 Linus Torvalds,芬兰赫尔辛基大学的学生在网络新闻组里发布了一帖,要求大家给他既将要编写的操作系统一些建议,使他编写出更好的操作系统。他把这个项 目作为一个爱好,他说,它不会成为“专业的”。但是 10 年过去了,他与遍布世界的骇客们完成了一个叫做 Linux 的操作系统,其可与 Windows 2000 竞争服务器市场,现在正在进军桌面市场。Linux 为什么与众不同,是如何向传统软件企业发起挑战。




中文:操作系统革命
英文:Revolution OS
发行:2002年
地区:美国
语言:英语
导演: J.T.S. Moore
主演: Richard M. Stallman / Linus Torvalds
内容简介:在微软垄断下有一件东西永远它永远不会给你──真正的自由。也正是因为这个原因,不少先锋人物站出来反抗微软帝国,并努力建立一种新的操作系统──没有人为的限制,任何人都可以自由地使用。
为了记录这些人的艰苦历程,J.T.S. Moore 拍摄了全新的记录片──Revolution OS,向公众介绍这些建立Linux 操作系统,奋起反抗垄断的斗士的人生经历。
现在微软已经明显感到了来自Linux的压力。微软的首席执行官去年6月公开表示:”Linux 是一种癌症!”。但这丝毫不能影响 Linux 发展的步伐。

2010年2月24日星期三

PyQt4学习笔记二



第五章(Dialogs)


第五章主要讲了三种Dumb dialogs

  • Dumb dialogs

    1. 1.使用QLabel的方法setBuddy配置聚焦快捷键

      2.addLayout(self,QLayout,int(row),int(col),int(rowSpan),int(colSpan),Qt.Alignment);-1表示拓展到头


      3.buttonBox=QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)

         buttonBox.button(QDialogButtonBox.Ok).setDefault(True)

         layout.addWidget(buttonBox,3,0,1,3)

         self.connect(buttonBox,SIGNAL("accepted()"),self,SLOT("accept()"))

         self.connect(buttonBox,SIGNAL("rejected()"),self,SLOT("reject()"))


  • Standard dialogs


    1. 1.深拷贝浅拷贝复习


      • 浅拷贝:把列表里面的对象插入到新的列表对象里面,id不变(列表新,对象旧)

      • 深拷贝:建立新列表里面是新的对象(列表新,对象新)




      2.QMessageBox.warning(self,"标题栏","正文")

  • Smart Dialogs


    1. 1.Modeless模式

      • a.正则表达式punctuationRe=QRegExp(r"[,;:.]")
        QLineEdit.setValidator(QRegExpValidator(punctuationRe,self))

      • b.QLineEdit.setInputMask("X") 表示至少一个元素,有过滤器考虑到底内容是什么




      2.live模式

      • textEdited()信号/valueChanged()信号/toggled()信号






第六章(Main Windows)



  • 1.程序分块的方法

    1. 主窗口一个

      各个dlg开一个新文件

      qrc_resource.py资源统一变成模块定位

  • 2.import推荐顺序先标准库,后第三方库

  • 3.QPrinter将在chap13里面讲

  • 4.以action的方式创建menu

    1. QAction

      QActionGroup

      用QMainWindow的m.menuBar().addMenu()来创建菜单

  • 5.m.addToolBar(s)创建工具栏

  • 6.用QSetting()保存应用程序的状态,保存在当前用户的目录下,~/.configs/...

  • 7.QInputDialog.getInteger()/.getDouble()/.getItem()/.getText()/

  • 8.使用pyrcc4编译对象,将.qrc资源文件统一成py模块,然后引用只要/xxx.png就可以了

  • 9.使用pyuic4从designer产生的.ui文件编译为.py模块


Programming Is Like Sex


because…




  • One mistake and you have to support it for the rest of your life. (Michael Sinz)

  • Once you get started, you’ll only stop because you’re exhausted.

  • It takes another experienced person to really appreciate what you’re doing.

  • Conversely, there’s some odd people who pride themselves on their lack of experience.

  • You can do it for money or for fun.

  • If you spend more time doing it than watching TV, people think you’re some kind of freak.

  • It’s not really an appropriate topic for dinner conversation.

  • There’s not enough taught about it in public school.

  • It doesn’t make any sense at all if you try to explain it in strictly clinical terms.

  • Some people are just naturally good.

  • But some people will never realize how bad they are, and you’re wasting your time trying to tell them.

  • There are a few weirdos with bizarre practices nobody really is
    comfortable with.

  • One little thing going wrong can ruin everything.

  • It’s a great way to spend a lunch break.

  • Everyone acts like they’re the first person to come up with a new technique.

  • Everyone who’s done it pokes fun at those who haven’t.

  • Beginners do a lot of clumsy fumbling about.

  • You’ll miss it if it’s been a while.

  • There’s always someone willing to write about the only right way to do things.

  • It doesn’t go so well when you’re drunk, but you’re more likely to do it.

  • Sometimes it’s fun to use expensive toys.

  • Other people just get in the way.