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