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

Offline mayureshkathe

  • Jr. Member
  • *
  • Posts: 2
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: 2384
  • 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