How can I link an .o file using g++

﹥>﹥吖頭↗ 提交于 2019-12-23 07:09:33

问题


I am trying to use g++ to compile a .cc file, and I need it to link a .o file.

So I tried:

$g++ -o client -I../ipc -L../messages.o client.cc
/usr/bin/ld: error: ../messages.o: can not read directory: Not a directory

And I have tried:

$g++ -o client -I../ipc -l../messages.o client.cc
/usr/bin/ld: error: cannot find -l../messages.pb.o
$$ ls -l ../messages.o

-rw-r--r-- 1 hap497 hap497 227936 2010-02-03 22:32 ../messages.o

Can you please tell me how to link in a .o file?

Thank you.


回答1:


$g++ -o client -I../ipc client.cc ../messages.o


来源:https://stackoverflow.com/questions/2203592/how-can-i-link-an-o-file-using-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!