Skip to content

undefined symbol for architecture: _glfwGetCocoaWindow #2610

@Gamer069

Description

@Gamer069

I have this premake file:

workspace "FuncDoodle"
    configurations { "Debug", "Release" }

glad_sources = {
    "lib/glad/src/glad.c"
}
imgui_sources = {
    "lib/imgui/imgui.cpp",
    "lib/imgui/imgui_**.cpp",
    "lib/imgui/imgui.h",
    "lib/imgui/backends/imgui_impl_glfw.cpp",
    "lib/imgui/backends/imgui_impl_opengl3.cpp",
    "lib/imgui/backends/imgui_impl_glfw.h",
    "lib/imgui/backends/imgui_impl_opengl3.h"
}
glfw_sources = {
    "lib/glfw/src/context.c",
    "lib/glfw/src/init.c",
    "lib/glfw/src/input.c",
    "lib/glfw/src/monitor.c",
    "lib/glfw/src/platform.c",
    "lib/glfw/src/vulkan.c",
    "lib/glfw/src/window.c",
    "lib/glfw/src/egl_context.c",
    "lib/glfw/src/osmesa_context.c",
    "lib/glfw/src/null_init.c",
    "lib/glfw/src/null_monitor.c",
    "lib/glfw/src/null_window.c",
    "lib/glfw/src/null_joystick.c",
    "lib/glfw/src/cocoa_time.c",
    "lib/glfw/src/posix_module.c",
    "lib/glfw/src/posix_thread.c",
    "lib/glfw/src/cocoa_init.m",
    "lib/glfw/src/cocoa_joystick.m",
    "lib/glfw/src/cocoa_monitor.m",
    "lib/glfw/src/cocoa_window.m",
    "lib/glfw/src/nsgl_context.m",
}

project "A"
    kind "ConsoleApp"
    language "C++"
    cppdialect "C++11"
    targetdir "bin/%{cfg.buildcfg}"

    files { glad_sources, glfw_sources, imgui_sources, "src/**.cc" }

    includedirs { "lib/glfw/include/", "lib/imgui", "lib/imgui/backends", "lib/glad/include" }

    links { "m", "pthread" }

    filter { "files:**.m" }
        compileas "Objective-C"
    -- Link against GLFW
    filter "system:macos"
        links { "GLFW", "dl", "Cocoa" }
        linkoptions { "-framework OpenGL", "-framework Cocoa", "-framework IOKit" }
        buildoptions { "-w" }
        defines {
            "_GLFW_COCOA"
        }
    filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"

    filter "configurations:Release"
        defines { "NDEBUG" }
        optimize "On"

and for some reason it complains about glfwGetCocoaWindow not being defined even though cocoa_window.m is compiled

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions