简体   繁体   English

使用目标文件在C ++中链接事物

[英]linking things in c++ using object file

PROBLEM SOLVED::: 问题解决了:::

I am using LEDA library in c++. 我在C ++中使用LEDA库。

command used to make object file.

g++ -I$LEDAROOT/incl -c mult.cpp

this command runs fine

I am getting eroor while linking step. 链接步骤时,我变得无能为力了。

HERE IS THE EROOR 这里是错误

varun@Kinley:~/Documents/LEDA/test/numbers$ g++  -L$LEDAROOT mult.o -lleda -lX11 -lm
/usr/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit status

I think I need to install some package,because when I googled this error the most of problems are solved by installing some package . 我想我需要安装一些软件包,因为当我搜索该错误时,大多数问题都可以通过安装一些软件包来解决。

I didn't find lx11 error 我没有找到lx11错误

some of the eroor messages that I googled. 我用Google搜索的一些错误信息。

error 1 错误1

/usr/bin/ld: cannot find -lfreetype collect2: ld returned 1 exit status / usr / bin / ld:找不到-lfreetype collect2:ld返回1退出状态

error 2 错误2

/usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status / usr / bin / ld:找不到-lz collect2:ld返回1退出状态

Links where I find these posts 我找到这些帖子的链接

http://www.qtcentre.org/threads/21069-collect2-ld-returned-1-exit-status http://www.qtcentre.org/threads/21069-collect2-ld-returned-1-exit-status

http://www.cyberciti.biz/faq/centos-rhel-redhat-usrbinld-cannot-findlc-error/ http://www.cyberciti.biz/faq/centos-rhel-redhat-usrbinld-cannot-findlc-error/

Do I need to install some package or there is some other problem 我需要安装一些软件包还是有其他问题?

Could be two things 可能是两件事

1) The X11 library is installed in a non-standard path. 1)X11库安装在非标准路径中。 Use the search command to see if libX11.a or libX11.so is available on your system. 使用搜索命令查看libX11.a或libX11.so在系统上是否可用。 If yes add the directory path to the -L option. 如果是,则将目录路径添加到-L选项。

2) You are missing the libX11 library. 2)您缺少libX11库。 In this case, login as admin and use yum (assuming linux) to install this library. 在这种情况下,以admin身份登录并使用yum(假设linux)安装此库。 Eg: 例如:

"yum install libX11.i386" or "yum install libX11.x86_64", depending on your architecture (32 bit or 64 bit). “ yum install libX11.i386”或“ yum install libX11.x86_64”,具体取决于您的体系结构(32位或64位)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM