Home > Software engineering >  Linkers: file was built for archive which is not the architecture being linked (x86_64) GLFW
Linkers: file was built for archive which is not the architecture being linked (x86_64) GLFW

Time:09-24

Hello, this problem make me crazy and i need your help. I am on a IOS High Sierra v10.13.6 and i am trying to try OpenGL on VSC on mac without XCode. So i have downloaded the library GLFW for the right OS. I have tried the basic exemple from the enter image description here

When i do this command:

g   -v main.cpp -o main.o -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework OpenGL

I have the following error in the terminal:

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

I understand that i came from this warning:

ld: warning: ignoring file /Library/Developer/CommandLineTools/usr/include/libglfw3.a, file was built for archive which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/usr/include/libglfw3.a

I have checked the library with the lipo command and it say that his architecture is x86_64! I don't know why it does not work, can you help me?

Thanks in advance.

CodePudding user response:

i want to say that i have found the solution for my problems. You have to double check that the library libglfw3.a is compiled in the good architecture witch is the x86_64.

Here the official link to download the GLFW library in the right OS

Also here is the command you need to run for make it compile:

You need to make sure to specify the path to the library through -L

g   main.cpp -o main -L/Library/Developer/CommandLineTools/usr/include -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit

Hope it will help for the futur dev who are stuck in the same problem

  • Related