Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22304

Why do I have to compile with `-static`? [duplicate]

$
0
0

I have the following assembly code

        global   main         extern   println        section  .textmain:        mov rdi, message        call     println        retmessage:        db "Hello, world!", 0

I am linking it with some C code

#include <stdio.h>void println(char *line) {    puts(line);}

I run the following commands to compile and link these two programs

nasm -f elf64 helloWorld.asm -o helloWorld.asm.ogcc -c helloWorld.c -o helloWorld.c.ogcc -static helloWorld.c.o helloWorld.asm.o -o helloWorld

then I run my finished program with

./helloWorld

If I remove -static from the gcc options, I get a seg-fault! Why is this??


Viewing all articles
Browse latest Browse all 22304

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>