質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

0回答

1547閲覧

OpenGL, glewのインクルードエラー

Petro

総合スコア12

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2019/03/19 02:49

前提・実現したいこと

glewをインクルードしたいです。

発生している問題・エラーメッセージ

fatal error:
'GL/glew.h' file not found

該当のソースコード

C++

1#include <GL/glew.h>

試したこと

macを使用しています。glewはインストールできていると思います。
可能な限り似たような質問を探してみましたが解決に至りませんでした。
brew list glew によるとglewは下のようになっています。
何かお心当たりのある方がいましたら、よろしくお願いいたします。

/usr/local/Cellar/glew/2.1.0/bin/glewinfo
/usr/local/Cellar/glew/2.1.0/bin/visualinfo
/usr/local/Cellar/glew/2.1.0/include/GL/ (3 files)
/usr/local/Cellar/glew/2.1.0/lib/libGLEW.2.1.0.dylib
/usr/local/Cellar/glew/2.1.0/lib/cmake/ (4 files)
/usr/local/Cellar/glew/2.1.0/lib/pkgconfig/glew.pc
/usr/local/Cellar/glew/2.1.0/lib/ (3 other files)
/usr/local/Cellar/glew/2.1.0/share/doc/ (20 files)

補足情報(FW/ツールのバージョンなど)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Stan_Dma

2019/03/19 04:14 編集

You have to speficy the include diretory like "-I/usr/local/Cellar/glew/2.1.0/include" when using it because the package has installed in the non-standard location.
Petro

2019/03/19 08:48

Stan_Dmaさん、stdioさん、 お答えくださりありがとうございます。 Xcodeではなくterminal上でpythonがc++ライブラリを使っているのでterminal上でmakeしています。 Stan_Dmaさんのおっしゃるようにパスをbash_profileに export PATH=$PATH:/usr/local/Cellar/glew/2.1.0/include としてみたのですがやはりnot foundとなります。 通すパスとしてはこの下にGL/glew.hがあるので良いかと思うのですが・・・ なんども申し訳ありませんが、何か間違っていましたら教えていただけると助かります。 よろしくお願いいたします。
Stan_Dma

2019/03/19 09:14 編集

The PATH is system search paths for the executables to execute. What you have to do is to set the header files to include.
Petro

2019/03/19 09:33

Thank you for your quick reply. I did like this: export PATH=$PATH:/usr/local/Cellar/glew/2.1.0/include/GL/glew.h but the make command complains again. I wonder this is not what you meant? Thank you.
Stan_Dma

2019/03/19 10:10

Don't do that. You don't have to set the PATH variable. Assume that your c++ source file is called test.cpp, which includes GL/glew.h. Then you can compile it with a command line command like 'cc -I/usr/local/Cellar/glew/2.1.0/include test.cpp -o test'.
Petro

2019/03/19 14:40

Thank you very much again. Actually, what I'm doing on terminal is $project/build>>make and some file named ~.cpp, as you noticed, returns the error. So I have not been compiling like that. In this case, can I export the path of GL/glew.h to let any programs to see the directory, or should I modify the corresponding lines in the make file as you suggested? Thank you.
Stan_Dma

2019/03/19 23:37 編集

Unclear about your situation. Makefile is created by yourself? Auto-generated one, by autotools or cmake? A simple workaround is to do in prompt like "CXXFLAGS='-I/usr/local/Cellar/glew/2.1.0/include make". Or you may need to add a line near the top of the Makefile like the same: "CXXFLAGS='-I/usr/local/Cellar/glew/2.1.0/include '" (CXXFLAGS might be CFLAGS).
Stan_Dma

2019/03/19 23:49

Should your Makeifle simply write the compile clause like "cc test.cpp -o test", you should rewrite it like following: "cc ${CXXFLAGS} test.cpp -o test" By the way, you might not go around like that if the glew library would be installed in a standard location.
Petro

2019/03/19 23:51

Thank you, Stan_Dma, The Makefile is not my project and I'm trying to compile the following library that wraps a C++ library with python: https://github.com/uoip/pangolin make -j4 (instead of -j8 in my case) returns the error in the file pangolin/python/pangolin.cpp Thank you.
Petro

2019/03/19 23:56

Sorry for my crisscrossing over your last message. As you say, I should have installed the glew library in a standard location. I wonder you mean the standard location as /usr/local/bin? If so, should I uninstall glew and reinstall it in /usr/local/bin? Thank you.
Stan_Dma

2019/03/20 01:26 編集

Say, lack of information. I heard that you have used cmake-build project. Another way, as convention, may be there specifying an option "-D<some_include_dir_to_be_added>" to define the location of the header files. I cannot point it out now.
Petro

2019/03/20 02:27

Thank you. I am sorry for confusing you. Here I will summarize what I am mainly wondering about: Some libraries are included in usr/local/Cellar folder, such as glew, glfw, eigen, boost, etc. And make command will start compiling some cpp files, but cannot find GL/glew.h from the Cellar folder. Can I always refer the libraries in usr/local/Cellar folder as well as usr/local/bin folder? Thank you.
Stan_Dma

2019/03/20 05:22

Sorry I dont know anything about mac and brew. I have read https://github.com/Homebrew/legacy-homebrew/issues/13068 and I see that /usr/local/Cellar/glew/2.1.0/include is symlinked by /usr/local/include, it's just a standard location! Sounds strange why you are in trouble. Something went wrong. Sorry I have no clue except that the symlink might be broken. I would only recommend to brew-install again the glew package.
Petro

2019/03/20 05:41

Thank you Stan_Dma, I see that what you pointed out must be the reason of my trouble. Actually, in /usr/local/include/GL directory do I find glew.h file. I think this is the symbolic link of /usr/local/Cellar. So it seems that I have the symlink. I will throw another question focusing this issue. Your comments were of great help for me to grasp the issue. Thank you very much! :)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問