我是一个不熟练的程序员,也是Linux的新手,我在编译时遇到了问题.我在同一文件夹中有两个文件'ex_addinst.c'和'lindo.h',我输入命令:
g++ -c ex_addinst.c
Run Code Online (Sandbox Code Playgroud)
然后,一个目标文件ex_addinst.o被发出警告:
ex_addinst.c: In function ‘int main()’:
ex_addinst.c:80: warning: deprecated conversion from string constant to ‘char*’
Run Code Online (Sandbox Code Playgroud)
然后我把它们泄漏了
g++ -Wall -o ex_addinst ex_addinst.o
Run Code Online (Sandbox Code Playgroud)
并获得以下信息:
ex_addinst.o: In function `main':
ex_addinst.c:(.text+0x2b): undefined reference to `LSloadLicenseString'
ex_addinst.c:(.text+0x75): undefined reference to `LSgetVersionInfo'
ex_addinst.c:(.text+0xae): undefined reference to `LScreateEnv'
ex_addinst.c:(.text+0x10a): undefined reference to `LSgetErrorMessage'
...
...
ex_addinst.c:(.text+0x1163): undefined reference to `LSdeleteEnv'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我想头文件'lindo.h'没有编译到.o文件中,但我不知道现在要做什么.我尝试过gcc,但得到同样的错误.我的g ++和gcc的版本是4.4.5.我正在使用Ubuntu 10.10.
所有的功能和结构都在'lindo.h'中声明.
ex_addinst.c的一部分如下:
#include <stdio.h>
#include <stdlib.h>
/* LINDO API header file */
#include "lindo.h" …Run Code Online (Sandbox Code Playgroud)