当前位置: 技术问答>linux和unix
red hat 9.0下程序库的配置
来源: 互联网 发布时间:2015-08-04
本文导语: 我用gcc编译时,有时会用到一些库,如Berkely db,popt等,,但是不能自动找到库,要让我手动查找,然后把库到路径和库名加到最后才能编译通过.请问一下,,应该怎么配置才行。 拿下面到程序来说: //win.c #include ...
我用gcc编译时,有时会用到一些库,如Berkely db,popt等,,但是不能自动找到库,要让我手动查找,然后把库到路径和库名加到最后才能编译通过.请问一下,,应该怎么配置才行。
拿下面到程序来说:
//win.c
#include
#include
#include
#include
#include
Display *display;
...........................
编译:
[root@localhost use2]# gcc -o win win.c -lXm -lXt -lX11
/usr/bin/ld: cannot find -lXm
collect2: ld returned 1 exit status
[root@localhost use2]# gcc -o win win.c
/tmp/cc7bBYfn.o(.text+0x3b): In function `setUpGCs':
: undefined reference to `XCreateBitmapFromData'
/tmp/cc7bBYfn.o(.text+0x79): In function `setUpGCs':
: undefined reference to `XCreateGC'
/tmp/cc7bBYfn.o(.text+0x99): In function `setUpGCs':
: undefined reference to `XCreateGC'
/tmp/cc7bBYfn.o(.text+0xd7): In function `setUpGCs':
: undefined reference to `XSetForeground'
/tmp/cc7bBYfn.o(.text+0x110): In function `setUpGCs':
: undefined reference to `XSetBackground'
/tmp/cc7bBYfn.o(.text+0x12f): In function `setUpGCs':
: undefined reference to `XSetLineAttributes'
/tmp/cc7bBYfn.o(.text+0x149): In function `setUpGCs':
: undefined reference to `XSetStipple'
/tmp/cc7bBYfn.o(.text+0x162): In function `setUpGCs':
: undefined reference to `XSetFillStyle'
/tmp/cc7bBYfn.o(.text+0x1a6): In function `drawInToWindow':
: undefined reference to `XDrawString'
/tmp/cc7bBYfn.o(.text+0x1d1): In function `drawInToWindow':
: undefined reference to `XDrawRectangle'
/tmp/cc7bBYfn.o(.text+0x203): In function `drawInToWindow':
: undefined reference to `XFillArc'
/tmp/cc7bBYfn.o(.text+0x222): In function `main':
: undefined reference to `XOpenDisplay'
/tmp/cc7bBYfn.o(.text+0x2e4): In function `main':
: undefined reference to `XCreatSimpleWindow'
/tmp/cc7bBYfn.o(.text+0x305): In function `main':
: undefined reference to `XSelectInput'
/tmp/cc7bBYfn.o(.text+0x325): In function `main':
: undefined reference to `XGetDefault'
/tmp/cc7bBYfn.o(.text+0x354): In function `main':
: undefined reference to `XMapWindow'
/tmp/cc7bBYfn.o(.text+0x36a): In function `main':
: undefined reference to `XNextEvent'
collect2: ld returned 1 exit status
我/ect/ld.so.conf中到内容是:
/usr/lib
/usr/lib
/usr/kerberos/lib
/usr/X11R6/lib
/usr/lib/sane
/usr/lib/qt-3.1/lib
/usr/lib/mysql
请问应该在哪里修改????????????????
拿下面到程序来说:
//win.c
#include
#include
#include
#include
#include
Display *display;
...........................
编译:
[root@localhost use2]# gcc -o win win.c -lXm -lXt -lX11
/usr/bin/ld: cannot find -lXm
collect2: ld returned 1 exit status
[root@localhost use2]# gcc -o win win.c
/tmp/cc7bBYfn.o(.text+0x3b): In function `setUpGCs':
: undefined reference to `XCreateBitmapFromData'
/tmp/cc7bBYfn.o(.text+0x79): In function `setUpGCs':
: undefined reference to `XCreateGC'
/tmp/cc7bBYfn.o(.text+0x99): In function `setUpGCs':
: undefined reference to `XCreateGC'
/tmp/cc7bBYfn.o(.text+0xd7): In function `setUpGCs':
: undefined reference to `XSetForeground'
/tmp/cc7bBYfn.o(.text+0x110): In function `setUpGCs':
: undefined reference to `XSetBackground'
/tmp/cc7bBYfn.o(.text+0x12f): In function `setUpGCs':
: undefined reference to `XSetLineAttributes'
/tmp/cc7bBYfn.o(.text+0x149): In function `setUpGCs':
: undefined reference to `XSetStipple'
/tmp/cc7bBYfn.o(.text+0x162): In function `setUpGCs':
: undefined reference to `XSetFillStyle'
/tmp/cc7bBYfn.o(.text+0x1a6): In function `drawInToWindow':
: undefined reference to `XDrawString'
/tmp/cc7bBYfn.o(.text+0x1d1): In function `drawInToWindow':
: undefined reference to `XDrawRectangle'
/tmp/cc7bBYfn.o(.text+0x203): In function `drawInToWindow':
: undefined reference to `XFillArc'
/tmp/cc7bBYfn.o(.text+0x222): In function `main':
: undefined reference to `XOpenDisplay'
/tmp/cc7bBYfn.o(.text+0x2e4): In function `main':
: undefined reference to `XCreatSimpleWindow'
/tmp/cc7bBYfn.o(.text+0x305): In function `main':
: undefined reference to `XSelectInput'
/tmp/cc7bBYfn.o(.text+0x325): In function `main':
: undefined reference to `XGetDefault'
/tmp/cc7bBYfn.o(.text+0x354): In function `main':
: undefined reference to `XMapWindow'
/tmp/cc7bBYfn.o(.text+0x36a): In function `main':
: undefined reference to `XNextEvent'
collect2: ld returned 1 exit status
我/ect/ld.so.conf中到内容是:
/usr/lib
/usr/lib
/usr/kerberos/lib
/usr/X11R6/lib
/usr/lib/sane
/usr/lib/qt-3.1/lib
/usr/lib/mysql
请问应该在哪里修改????????????????
|
是-lXm这个库没找到,用-L指定一下这个库文件的路径吧。
ld.so.conf只是在运行时才起作用的,编译时不看这个。
ld.so.conf只是在运行时才起作用的,编译时不看这个。