Giter VIP home page Giter VIP logo

Comments (6)

rsepassi avatar rsepassi commented on May 30, 2024 1

I think that works, thanks!

from zig.

xdBronch avatar xdBronch commented on May 30, 2024

is this not the default behavior when you dont pass -lc?

int main() {}

compiling this with gcc/clang and passing -nostdlib -nostdinc will give a linking error about not finding _start and segfaults if you try to run the program. the exact same thing happens when running zig build-exe with no additional flags.
is the difference something to do with different platforms?

edit: this was possibly not the best way to represent it but my point is that without -lc zig doesnt use any of the standard library. if you try to include any libc headers it will fail as well

from zig.

rsepassi avatar rsepassi commented on May 30, 2024

So it was my understanding (and I believe observation, though I don't have a neatly packaged test, so the observation could be suspect) that nostdinc and nostdlib also removed default search paths for includes and libraries, e.g. /usr/include /usr/lib etc.

from zig.

xdBronch avatar xdBronch commented on May 30, 2024

thats my understanding as well which as far as im aware is the same behavior for zig unless youre linking libc. though interestingly i just tested and gcc seems to keep the library search paths, if i do e.g. gcc a.c -nostdinc -nostdlib -lraylib it is still able to link raylib as well as libc and libm etc.

from zig.

rsepassi avatar rsepassi commented on May 30, 2024

hmm..so in my use case I am often linking libc, but I don't want zig to go searching /usr for headers and libraries for other things (headers mostly; libraries I have more control over because I'm often building static archives and explictly passing the .a instead of using -l, though sometimes it'd be nice to pass a command-line to CC= somewhere and know that it will only look where I told it to). I think if I explicitly specify -target (even if it is for the current host platform) it won't go looking, is that right?

from zig.

kassane avatar kassane commented on May 30, 2024

Try:

zig build-lib -cflags -nostdlib -- <zig-flags> -cflags -nostdinc -- file.zig

from zig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.