2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

glfwを使うプログラムをターミナル上でコンパイル

Last updated at Posted at 2016-12-31

はじめに

ピンポイントでハマったので
敢えてmacのターミナルでOpenGLをやってみようと思い立つも
glfwのサンプルをコンパイルしようにもリンクのエラー吐いて困ったので色々調べてみた。

glfwのインストール

makeしてもいいけど簡単に管理したいのでhomebrewで
stowとか使えば管理できるかなって思ったけどconfigureしないので、余談だけど

$ brew install glfw3

特に変わったこともない。

すると/usr/local/includeにGLFW/glfw3.hができてるのでそのままでおk
適当なcppファイルで#include をインクルード
コンパイルするときには

$ clang++ -o main main.cpp -lglfw -framework OpenGL

以上

これをやらないと

Undefined symbols for architecture x86_64:
  "_glClear", referenced from:
      _main in main-28d7a8.o
  "_glfwCreateWindow", referenced from:
      _main in main-28d7a8.o
  "_glfwInit", referenced from:
      _main in main-28d7a8.o
  "_glfwMakeContextCurrent", referenced from:
      _main in main-28d7a8.o
  "_glfwPollEvents", referenced from:
      _main in main-28d7a8.o
  "_glfwSwapBuffers", referenced from:
      _main in main-28d7a8.o
  "_glfwTerminate", referenced from:
      _main in main-28d7a8.o
  "_glfwWindowShouldClose", referenced from:
      _main in main-28d7a8.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

みたいなエラーがでる。(よくわからん)

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?