ml-explore / ml-explore/mlx-c

Beginner question: How to build a program?

Open
#90 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
243
Forks
89
Avg merge
14d 43m
Merged PRs (30d)
2

Description

I am exploring MLX-C for fun. I have already built the library and used make install to install the headers and libraries. They got installed at the path /usr/local/include/ and /usr/local/lib/. As a test program, I wrote the following:

#include<stdio.h>
#include "mlx/c/mlx.h"

int main(){
  printf("GPU information\n");
  printf("---------------");
  mlx_metal_device_info_t info = mlx_metal_device_info();
  printf("Architecture:\t%s\n", info.architecture);
  printf("Maximum buffer length:\t%ld\n", info.max_buffer_length);
  printf(
	 "Max recommended working set size:\t%ld\n",
	 info.max_recommended_working_set_size);
  printf("Memory size:\t%ld\n", info.memory_size);
  return 0;
}

With the build command below, I get errors:

clang -I/usr/local/include -L/usr/local/lib test.c -o test 
Undefined symbols for architecture arm64:
  "_mlx_metal_device_info", referenced from:
      _main in test-7c0886.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What is the correct way to build?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test.c, the included mlx/c/mlx.h header, and the library artifacts installed under /usr/local/lib. Check the project's build configuration to determine which library must be passed to clang during linking. Done means the command builds and links the program successfully on arm64.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
api, build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.