PDA

View Full Version : glew architecture x86_64 error



mehrschwein
03-14-2015, 10:14 AM
Hi,
I used glut and sdl2 before and now i tried to make something completely on my own with openGL, sdl2 and glew. I wrote my own makefile now and i think it works, but i always get this error when i try to compile it:



g++ -c -Wall -I/usr/local/include main.cpp
g++ -c -Wall -I/usr/local/include Display.cpp
g++ -L/usr/local/lib -lSDL2 -lGLEW -o booom main.o Display.o
Undefined symbols for architecture x86_64:
"_glClear", referenced from:
Display::Clear(float, float, float, float) in Display.o
"_glClearColor", referenced from:
Display::Clear(float, float, float, float) in Display.o
"_glCullFace", referenced from:
Display::Display(int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Display.o
"_glEnable", referenced from:
Display::Display(int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Display.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1


I have only my main.cpp and my Display class. This small program should only create a window for me.

I try to compile it on osx, version 10.9.5.
glew version: 1.12.0 (compiled on my own, also tried it with the homebrew version. changes nothing)
sdl2 version: 2.0.3

Here is my makefile:



#my compiler
CC=g++

#my program name
PRGNAME=booom

#library search directory
LIBDIR=-L/usr/local/lib

#library names
#uses libSDL2.a, libGLEW.a
LIBNAME=-lSDL2 -lGLEW

#includes for libraries
INCLUDES=-I/usr/local/include

#my compiler options
CFLAGS=-c -Wall


all: main.o Display.o
$(CC) $(LIBDIR) $(LIBNAME) -o $(PRGNAME) main.o Display.o

#main.cpp is the dependency of main.o
main.o: main.cpp
$(CC) $(CFLAGS) $(INCLUDES) main.cpp

Display.o: Display.cpp
$(CC) $(CFLAGS) $(INCLUDES) Display.cpp

clean:
rm -rf *o booom


i searched a lot on google,but i haven't found a fix that works for me. also most people on osx use xcode, but i don't want to use xcode anymore because its osx only.

Dark Photon
03-14-2015, 08:29 PM
Hi,
I used glut and sdl2 before and now i tried to make something completely on my own with openGL, sdl2 and glew. I wrote my own makefile now and i think it works, but i always get this error when i try to compile it:



g++ -c -Wall -I/usr/local/include main.cpp
g++ -c -Wall -I/usr/local/include Display.cpp
g++ -L/usr/local/lib -lSDL2 -lGLEW -o booom main.o Display.o
Undefined symbols for architecture x86_64:
"_glClear", referenced from:
Display::Clear(float, float, float, float) in Display.o
"_glClearColor", referenced from:
Display::Clear(float, float, float, float) in Display.o...

Don't know about OSX, but most (all Linux distros) put 32-bit libs in .../lib and 64-bit libs in .../lib64.

Instead try: -L/usr/local/lib64 (if youre OSX box has your 64-bit libGL.* libs in /usr/local/lib64). Normally the GL libs are placed in a system directory so you don't even need a -L argument to help the linker find them.

arekkusu
03-14-2015, 10:54 PM
Don't know about OSX
OSX uses fat binaries (http://en.wikipedia.org/wiki/Fat_binary#Mach-O_and_Mac_OS_X). All of the GL-related libraries shipped with the system are fat.


Undefined symbols for architecture x86_64
Try the "file" command on each of the libs you are linking. Fix your build for whichever one isn't x86_64 (i.e. add "-arch x86_64".)


i don't want to use xcode anymore because its osx only.
Nothing wrong with that. But you might look at an Xcode build log to see all the flags you might need to replicate in your make.

mehrschwein
03-21-2015, 09:09 AM
Thank you for your help, but i wasn't able to solve to problem yet. when compiling glew i get some warnings about deprecated functions. glew uses AGL to compile on OS X and i don't know if it may have something to do with this (https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/AGL_OpenGL/#//apple_ref/c/func/aglCreatePixelFormat).
It also uses the -arch x86_64 option already.
I also tryed to build it with xcode now to see if i need to change something in my makefile, but i get the same error. Somehow he doesn't want to give me a good glew version for my architecture.

mehrschwein
03-21-2015, 11:34 AM
well, seams like AGL is not supported anymore and is only for 32-bit.

arekkusu
03-22-2015, 01:13 AM
AGL is fat:

$ file /System/Library/Frameworks/AGL.framework/Versions/A/AGL
/System/Library/Frameworks/AGL.framework/Versions/A/AGL: Mach-O universal binary with 2 architectures
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (for architecture i386): Mach-O dynamically linked shared library i386
...however AGL depends on Carbon for the window interface, which is certainly deprecated.

mehrschwein
03-22-2015, 05:00 AM
any idea how i can work around that? i need glew and can't get it working :(
Im not sure if its even AGL what creates my problem. AGL only gives warnings when compiling glew, but it may not be my problem. anyone out there with OS X 10.10 who made glew work and was able to use it?

arekkusu
03-22-2015, 12:56 PM
Try linking OpenGL:

LIBNAME=-lSDL2 -lGLEW -framework OpenGL

mehrschwein
03-23-2015, 02:50 AM
well....... yea, it works now... thank you.
wow
i really forgot that

arkaedra
04-18-2015, 10:58 AM
I had the same problem and your solution works great for me!

Thank you so much :)


Try linking OpenGL:

LIBNAME=-lSDL2 -lGLEW -framework OpenGL