Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: glew architecture x86_64 error

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    5

    glew architecture x86_64 error

    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:

    Code :
    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:

    Code :
    #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.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,478
    Quote Originally Posted by mehrschwein View Post
    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:

    Code :
    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.

  3. #3
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    887
    Quote Originally Posted by Dark Photon View Post
    Don't know about OSX
    OSX uses fat binaries. All of the GL-related libraries shipped with the system are fat.

    Quote Originally Posted by mehrschwein View Post
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    5
    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/...atePixelFormat).
    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.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    5
    well, seams like AGL is not supported anymore and is only for 32-bit.

  6. #6
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    887
    AGL is fat:
    Code :
    $ 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.

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    5
    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?

  8. #8
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    887
    Try linking OpenGL:
    Code :
    LIBNAME=-lSDL2 -lGLEW -framework OpenGL

  9. #9
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    5
    well....... yea, it works now... thank you.
    wow
    i really forgot that

  10. #10
    Newbie Newbie
    Join Date
    Apr 2015
    Posts
    1
    I had the same problem and your solution works great for me!

    Thank you so much

    Quote Originally Posted by arekkusu View Post
    Try linking OpenGL:
    Code :
    LIBNAME=-lSDL2 -lGLEW -framework OpenGL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •