# Mac os cant find some of the symbols in the code

**URL:** <https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668>\
**Category:** support\
**Created:** [June 25, 2024, 4:17pm UTC](https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668 "2024-06-25T16:17:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mdotr](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@Mdotr](https://discourse.glfw.org/u/Mdotr)\
**Post date:** [June 25, 2024, 4:17pm UTC](https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668/1 "2024-06-25T16:17:17Z")

</div>

before the code was comiled no errors were there but once I compiled it there were some errors

code:

```auto
#include </Users/stavanmukherjee/Downloads/raylib-master/src/external/glfw/include/GLFW/glfw3.h>
#include <iostream>

int main() {
    // Initialize the GLFW library
    if (!glfwInit()) {
        std::cerr << "Failed to initialize GLFW" << std::endl;
        return -1;
    }

    // Set GLFW options
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    // Create a windowed mode window and its OpenGL context
    GLFWwindow* window = glfwCreateWindow(800, 600, "Hello World", nullptr, nullptr);
    if (!window) {
        std::cerr << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }

    // Make the window's context current
    glfwMakeContextCurrent(window);

    // Main loop
    while (!glfwWindowShouldClose(window)) {
        // Render here

        // Swap front and back buffers
        glfwSwapBuffers(window);

        // Poll for and process events
        glfwPollEvents();
    }

    // Clean up and exit
    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

```

errors:

```auto
Undefined symbols for architecture arm64:
  "_glfwCreateWindow", referenced from:
      _main in main.o
  "_glfwDestroyWindow", referenced from:
      _main in main.o
  "_glfwInit", referenced from:
      _main in main.o
  "_glfwMakeContextCurrent", referenced from:
      _main in main.o
  "_glfwPollEvents", referenced from:
      _main in main.o
  "_glfwSetErrorCallback", referenced from:
      _main in main.o
  "_glfwSwapBuffers", referenced from:
      _main in main.o
  "_glfwTerminate", referenced from:
      _main in main.o
      _main in main.o
  "_glfwWindowHint", referenced from:
      _main in main.o
      _main in main.o
      _main in main.o
  "_glfwWindowShouldClose", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture arm64

```

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [June 25, 2024, 5:57pm UTC](https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668/2 "2024-06-25T17:57:07Z")

</div>

These are link errors, you need to [link to GLFW as noted in the documentation](https://www.glfw.org/docs/latest/build_guide.html#build_link_xcode).

An alternative is to use the [GLFW-CMake-starter](https://github.com/enkisoftware/GLFW-CMake-starter) which uses CMake, follow the instructions in the readme.

---

<div class="post-metadata">

**Author:** ![Mdotr](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@Mdotr](https://discourse.glfw.org/u/Mdotr)\
**Post date:** [June 25, 2024, 7:06pm UTC](https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668/3 "2024-06-25T19:06:10Z")

</div>

ive tried doing that and it cant find glfw3.h

code:# Compiler

CXX = clang++

# Directories

SRC\_DIR = /Users/stavanmukherjee/Desktop/standardDefinitionLibrary

INC\_DIR = $(SRC\_DIR)/hppFiles

OBJ\_DIR = $(SRC\_DIR)/build/objectFiles

BIN\_DIR = $(SRC\_DIR)/build/executable

MEDIA\_DIR = $(SRC\_DIR)/media

# Source files

MAIN\_SRC = $(SRC\_DIR)/main.cpp

HPP\_FILES = $(wildcard $(INC\_DIR)/\*.hpp)

CPP\_FILES = $(wildcard $(SRC\_DIR)/\*.cpp)

OBJ\_FILES = $(patsubst $(SRC\_DIR)/%.cpp, $(OBJ\_DIR)/%.o, $(CPP\_FILES))

# Output executable

EXECUTABLE = $(BIN\_DIR)/your\_executable\_name

# Compiler and linker flags

CXXFLAGS = -I$(INC\_DIR) -std=c++11

LDFLAGS = -L/Users/stavanmukherjee/Desktop/standardDefinitionLibrary/hppFiles -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo

# Targets

all: setup $(EXECUTABLE)

setup: clean $(OBJ\_FILES)

$(EXECUTABLE): $(OBJ\_FILES)

mkdir -p $(BIN\_DIR)

$(CXX) $(OBJ\_FILES) -o $(EXECUTABLE) $(LDFLAGS)

cp -r $(MEDIA\_DIR)/\* $(BIN\_DIR)

$(OBJ\_DIR)/main.o: $(MAIN\_SRC) $(HPP\_FILES)

mkdir -p $(OBJ\_DIR)

$(CXX) $(CXXFLAGS) -c $(MAIN\_SRC) -o $(OBJ\_DIR)/main.o

$(OBJ\_DIR)/%.o: $(SRC\_DIR)/%.cpp $(HPP\_FILES)

mkdir -p $(OBJ\_DIR)

$(CXX) $(CXXFLAGS) -c $\< -o $@

clean:

rm -rf $(OBJ\_DIR) $(BIN\_DIR)

.PHONY: all setup clean

error:ld: library ‘glfw3’ not found  
clang: error: linker command failed with exit code 1 (use -v to see invocation)

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [June 26, 2024, 3:14pm UTC](https://discourse.glfw.org/t/mac-os-cant-find-some-of-the-symbols-in-the-code/2668/4 "2024-06-26T15:14:50Z")

</div>

Where is the location of the `libglfw3.a` file? This needs to be in a directory which you tell the linker about with `-L` in your `LDFLAGS` setting.

You have specified `-L/Users/stavanmukherjee/Desktop/standardDefinitionLibrary/hppFiles` which looks like it is the location of your _include files_. However this setting is for the location of your _lib files_ such as `libglfw3.a` to link to.

If you are instead linking to the dynamic GLFW library `libglfw.3.dylib` use `-lglfw` (you still need to set the directory location as above).

Hope this helps.
