Comments (6)
I think that works, thanks!
from zig.
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.
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.
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.
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.
Try:
zig build-lib -cflags -nostdlib -- <zig-flags> -cflags -nostdinc -- file.zig
from zig.
Related Issues (20)
- @cInclude("stdio.h") doesn't work for -Dtarget=wasm32-emscripten
- Unsure how to handle duplicate symbol linker error
- SIGTRAP When attempting to write to a runtime index in comptime variable HOT 1
- Undefined struct fields are initialized to 0 instead of 0xAA in debug mode (with llvm backend)
- zig fetch -h should include examples
- Zig build system incorrectly parses some depfiles generated by Rust on Windows
- implement std.Progress for single-threaded mode
- std.Progress: add byte unit flag and resource scope; support throughput calculation
- implement std.Progress IPC for WASI
- implement std.Progress IPC for Windows
- add support for targeting glibc 2.39
- Progress display is cut off horizontally HOT 2
- `zig fmt` outputs invalid syntax when formatting an error set with doc comments onto one line
- Latest master tarball is unable to build a stage4 zig HOT 3
- upperBound and lowerBound has inconsistent callback types HOT 1
- "offsetof" from C header does not handle union within struct HOT 2
- x86_64 backend miscomp
- When compiling for android, and linking libc, you will always hit a @compileError HOT 1
- Progress cuts off prints to the terminal HOT 2
- x86_64 backend `genSetReg called with a value larger than dst_reg`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zig.