Help compiling with gcc/g++

我只是一个虾纸丫 提交于 2020-01-07 04:20:49

问题


If I have a directory structure such as the tree below, what should my g++ command look like that would successfully compile the .cpp file that is in the taglib/bin dir, with all my .h files sitting in the taglib/include/taglib directory.

Anyones help would be greatly appreciated. Thank you!

-taglib

--bin
  .cpp file is here, incl headers are like this: #include <other.h>
  but wondering if it should be #include </taglib/include/taglib/other.h>,
  also, this should be where my binary will live when compiled.

--lib
  all my .so files live here

--include
---taglib
   all my .h files live here 

回答1:


The -I and -L options specify search directories for includes and libraries respectively. Therefore, you command should be something like:

g++ -o <xyz> taglib/bin/*.cpp -Iinclude/taglib -Llib

man gcc and even gcc --help gives great information on these particular command line options (and the GCC manual is fairly friendly too). You should really be trying them first before you ask here - it's more efficient (no waiting for answers!).



来源:https://stackoverflow.com/questions/4927682/help-compiling-with-gcc-g

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