Compile c++ file using external library from linux terminal

心已入冬 提交于 2019-12-11 05:06:34

问题


I have the following files:

ex1.cpp    ex1.h
GLee.cpp   GLee.h

and I want to make it use the library (openmesh library) on the following path:

home/xyz/Downloads/OpenMesh-2.3/src/OpenMesh/

I'm trying to execute it with this:

g++ -Wall -o ex1 ex1.cpp GLee.cpp -L/..path../

but no luck, output is:

In file included from ex1.cpp:17:0: ex1.h:28:38: fatal error: OpenMesh/Core/IO/MeshIO.hh: No such file or directory compilation terminated.

what is the correct way of doing this?

Thanks!


回答1:


You need to put -I path on the command line. So from the error, it looks like you would do:

g++ -Wall -o ex1 ex1.cpp GLee.cpp -I /home/xyz/Downloads/OpenMesh-2.3/src



回答2:


I would recommend you and everyone else who has the same problem to read this article I was having the same issue but after reading this I got it fixed, I hope it helps you, http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html



来源:https://stackoverflow.com/questions/13389842/compile-c-file-using-external-library-from-linux-terminal

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