在Solaris中,使用/ usr / sfw / bin / gcc时链接动态库错误

时间:2013-02-27 08:59:17

标签: c gcc hyperlink solaris

所有:
    我正在使用Solaris 10,并且遇到以下问题:

There is ODBC dynamic library in /usr/local/lib:

lrwxrwxrwx   1 root     root          16 Jun 26  2012 libodbc.so -> libodbc.so.2.0.0
lrwxrwxrwx   1 root     root          16 Jun 26  2012 libodbc.so.2 -> libodbc.so.2.0.0
-rwxr-xr-x   1 root     root     1874776 Jun 26  2012 libodbc.so.2.0.0  

makefile喜欢这个:

gcc  -o a a.c -lodbc

当我使用/ usr / local / bin / gcc来编译程序时,编译就可以了   但是当我使用/ usr / sfw / bin / gcc来编译程序时,会出现以下错误:

ld:致命:图书馆-lodbc:未找到

但是crle命令输出:

 Configuration file [version 4]: /var/ld/ld.config  
 Platform:     32-bit MSB SPARC
 Default Library Path (ELF):   /lib:/usr/lib:/usr/local/lib:/opt/DSI/32:/usr/local/asg_mysql/lib
 Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

 Command line:
 crle -c /var/ld/ld.config -l /lib:/usr/lib:/usr/local/lib:/opt/DSI/32:/usr/local/asg_mysql/lib

似乎没问题。

使用gcc时有什么区别吗?非常感谢提前!
最诚挚的问候 南萧

1 个答案:

答案 0 :(得分:1)

似乎/usr/local/lib不在链接器的默认搜索路径中。使用-L选项添加它:

$ /usr/sfw/bin/gcc your_file.c -o your_program -L/usr/local/lib -lodbc