Home > Mobile >  Link static C libraries with GoLink
Link static C libraries with GoLink

Time:08-07

I'm trying to make an SDL2 program with NASM and GoLink just for fun but I can't link SDL2main.a and SDL2 to my executable. I'm on a win64 architecture.

My main.asm


[bits 64]

extern ExitProcess

extern SDL_Init
extern SDL_Quit


SDL_INIT_VIDEO equ 0x00000020

section .text

    _start:
        mov rcx, SDL_INIT_VIDEO
        call SDL_Init

        call SDL_Quit

        xor rcx, rcx
        call ExitProcess

and this is the way I build my .exe :

nasm -f win64 main.asm -o main.obj
.\GoLink.exe /console /entry _start /fo prog.exe main.obj kernel32.dll

and I get the following error :

GoLink.Exe Version 1.0.4.1  Copyright Jeremy Gordon 2002-2022   [email protected]

Error!
The following symbols were not defined in the object file or files:-
SDL_Init
SDL_Quit
Output file not made

My static libs are located in a ./lib folder if it can help.

CodePudding user response:

GoLink doesn't understand the .a static library file format that MinGW based tool chains create. If you intend to use GoLink, you will need to get a copy of the SDL2 library that works with the Microsoft tools and linker.

In your case you will want the SDL2 development libraries for Visual C on their download page rather than the MinGW libraries that you are currently using.

  • Related