Author Topic: Using a C library with NASM without needing GCC  (Read 10321 times)

Offline mayureshkathe

  • Jr. Member
  • *
  • Posts: 3
Using a C library with NASM without needing GCC
« on: November 13, 2019, 01:54:10 AM »
I saw the tutorial at https://cs.lmu.edu/~ray/notes/nasmtutorial/  (Using a C Library).
It has an example to show usage of a C library with NASM, but the build process depends on GCC.
Is there any way to use an external non-assembly library with assembly using NASM?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Using a C library with NASM without needing GCC
« Reply #1 on: November 13, 2019, 03:11:00 AM »
Sure. You think HLLs have instructions that Nasm doesn't know?

It is much easier to use a linker. You'll have to figure out the command line to the linker. GCC knows the command line to tell the linker. Why don't you want to use it?

You'll need "-lc" and probably "-L(path to library)" - maybe others... I've lost my examples...
("--nostartfiles" to GCC to get rid of "main" as I recall)

Best,
Frank


Offline mayureshkathe

  • Jr. Member
  • *
  • Posts: 3
Re: Using a C library with NASM without needing GCC
« Reply #2 on: January 09, 2020, 12:45:51 AM »
I am currently learning assembler using NASM via books by Duntemann and others from Apress.
My long term ambition is to build a high-performance, high-precision, error-free library for numerical computing and then build applications using the same under macOS using it's AppKit UI library via the Metal interface.
I don't want to have the burden of downloading the entire XCode environment when all I need is an assembler and linker which I can ask a friend to build an installable package of.