I am using Mac Os X 10.9.5 fully updated with XCode version 6.0.1. I have also installed the command line utilities that have to be installed after installing XCode. I am using GLFW and GLEW in my openGL libraries. GLEW was installed manually while GLFW was installed with Macports.
I want to do coding without XCode as I have been doing it on Windows (with MingW) and Linux. I have googled how to compile the program and also searched on stackoverflow.
So, currently my compile command looks like this (This is a C++ program)
g++ -framework Cocoa -framework OpenGL -framework CoreFoundation -framework CoreVideo -framework IOKit -L/usr/lib -L/usr/local/lib -I/usr/include/GLFW -I/usr/local/include/GL main.cpp -o main
I keep on getting the following error:
Undefined symbols for architecture x86_64:
"_glfwCreateWindow", referenced from:
_main in main-ba7a57.o
"_glfwInit", referenced from:
_main in main-ba7a57.o
"_glfwMakeContextCurrent", referenced from:
_main in main-ba7a57.o
"_glfwTerminate", referenced from:
_main in main-ba7a57.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The program is:
#define GLEW_STATIC
#include <glew.h>
#include <glfw3.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
GLFWwindow* window;
if(!glfwInit()) exit(EXIT_FAILURE);
window = glfwCreateWindow(1024, 768, "glfw", NULL, NULL);
if(!window) {
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
const GLubyte* version = glGetString(GL_VERSION);
cout << "OpenGL version: " << version << endl;
glfwTerminate();
return 0;
}