linking glew

harsha
Unregistered
 
Post: #1
This has been asked lots of times before but I'm still having trouble with it. Any help would be great. In xcode I set the header search path as /usr/include/GL and the library search path as /usr/lib. When I run it I get an unknown symbol _glewinit.
Code:
#include <GL/glew.h>
int main (int argc, char * const argv[]) {
glewInit();
    return 0;
}
I tried doing this from the command line and got a bus error.
Code:
> g++ -g -Wall -Wno-unused-parameter -Wnewline-eof -Werror -o main main.cpp -lglew
>./main

Cheers for reading.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
what if you put
Code:
extern "C" {
#include <GL/glew.h>
}

?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
harsha
Unregistered
 
Post: #3
It produces the same error.
Code:
ZeroLink: unknown symbol '_glewInit'

Executable “glewtest” has exited due to signal 6 (SIGABRT).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
harsha Wrote:
Code:
#include <GL/glew.h>
int main (int argc, char * const argv[]) {
glewInit();
    return 0;
}
I tried doing this from the command line and got a bus error.
Code:
> g++ -g -Wall -Wno-unused-parameter -Wnewline-eof -Werror -o main main.cpp -lglew
>./main

Cheers for reading.

You can't call glewInit() before you have an OpenGL context.
Quote this message in a reply
harsha
Unregistered
 
Post: #5
Thanks for your reply. It's now working from the command line, however the error persists within xcode.

In the 'other linker flags' option I put -lglew, (while the project icon was selected). Should it be in a different option?

/edit
I dragged the glew library into the xcode project as instructed by this website. It works fine now. This is another good website describing what to do if anyone else runs into the same problem. Smile

/edit 2
Cookie also wrote a post on this on a different forum. link.
Quote this message in a reply
Post Reply