Have you tried ‘gcc -framework SDL2 -framework SDL2_image -o main main.c’? (or preferably clang instead of gcc.)On 2013-08-31, at 3:10 PM, Emir Kotan wrote:
Hello,
Stubborn gcc is being mean to me on OS X Lion.
I have a simple main.c file that contains bits of SDL2 and SDL_image code which compiles fine. Working directory:
I think Clang is a better choice in general in OS X - the GCC version provided with the Developer Tools is version 4.2 (ancient), whereas Clang tends to be the most recent as of when the version of Xcode used was released; it has more features available (C11 / C++11 support, link-time optimization, etc.)
It helps that Apple is developing Clang. Also the LLVM/Clang logo is kind of badass.
There’s very little reason to prefer gcc over clang in OS X these days, in my opinion.On 2013-08-31, at 4:43 PM, Emir Kotan wrote:
Oh, God! Thanks a lot! I completely forgot the “framework” option. Problem solved.
Is clang a better choice for C projects? I was also thinking about Tiny C Compiler but not sure.
On 31 Aug 2013, at 20:27, Alex Szpakowski wrote:
Have you tried ‘gcc -framework SDL2 -framework SDL2_image -o main main.c’? (or preferably clang instead of gcc.)
On 2013-08-31, at 3:10 PM, Emir Kotan wrote:
Hello,
Stubborn gcc is being mean to me on OS X Lion.
I have a simple main.c file that contains bits of SDL2 and SDL_image code which compiles fine. Working directory:
Tried clang a bit today and switched to it immediately, simply because its error reporting was prettier. And, yeah, the logo is awesome.
Thanks, again. You’ve saved me twice :)On 31 Aug 2013, at 21:46, Alex Szpakowski wrote:
I think Clang is a better choice in general in OS X - the GCC version provided with the Developer Tools is version 4.2 (ancient), whereas Clang tends to be the most recent as of when the version of Xcode used was released; it has more features available (C11 / C++11 support, link-time optimization, etc.)
It helps that Apple is developing Clang. Also the LLVM/Clang logo is kind of badass.
There’s very little reason to prefer gcc over clang in OS X these days, in my opinion.
On 2013-08-31, at 4:43 PM, Emir Kotan <@Emir_Kotan> wrote:
Oh, God! Thanks a lot! I completely forgot the “framework” option. Problem solved.
Is clang a better choice for C projects? I was also thinking about Tiny C Compiler but not sure.
On 31 Aug 2013, at 20:27, Alex Szpakowski wrote:
Have you tried ‘gcc -framework SDL2 -framework SDL2_image -o main main.c’? (or preferably clang instead of gcc.)
On 2013-08-31, at 3:10 PM, Emir Kotan <@Emir_Kotan> wrote:
Hello,
Stubborn gcc is being mean to me on OS X Lion.
I have a simple main.c file that contains bits of SDL2 and SDL_image code which compiles fine. Working directory:
Message-ID: <60601E82-B4D9-45E3-A5F0-DA9D78A56A19 at gmail.com>
Content-Type: text/plain; charset=us-ascii
Is clang a better choice for C projects? I was also thinking about Tiny C
Compiler but not sure.
Not sure about Clang vs. GCC, but as far as TCC goes, it’s like this:
For most purposes you should use something other than TCC, but there
are exceptions:
Scripting: TCC has a library version of itself, which allows you to
feed C into it and get a set of functions & such out as a result. If I
remember right, it even does this on Windows 8. In comparison,
everything else you’re fairly likely to need to call on the user’s
machine, with a command-line interface, which you’ll have to parse,
etc. TCC is also somewhat simple in the library interface. Advantage:
usually TCC.
Bootstrapping: Last that I heard (and presumably the last that any
one tried, sometime within the last year I think), TCC was fully
capable of compiling GCC. Thus, if you can get TCC cross-compiled
(hopefully much simpler than with GCC), then you can move it over to
the machine that you want GCC on, and start compiling that, at which
point you should hopefully be able to further bootstrap to full
functionality.
Size: If you want to compile within limited space for some reason,
but aren’t worried about the size of the executables (let’s say that
you have some fast built-in storage, and some slow SD card storage),
then TCC is almost guaranteed to be the best option, because few, if
any, compilers are as small as TCC.
Toys: What if you want to write a VM that uses C? Do you want to
modify GCC, write your own compiler, or modify TCC? What about using
TCC from the command line like some sort of obscene version of Forth?
How about playing with Quajects as implemented in C? How about a quick
test for the validity of your C? Points 1 and 3 above both say that
you’re probably better off with TCC when you want to make a toy that
uses a compiler, than anything else.
Now, for the caveats: TCC is not a main-line production compiler, it
was never intended to be, and probably never will be. TCC performs
ALMOST (but not quite) no optimizations, so the executables produced
by any other modern compiler will likely be both faster AND smaller.
TCC is small and fast for a compiler, but this comes at the cost of
almost all optimizations. TCC is most relevant for certain corner
cases: everywhere else you should look at one of it’s competitors
first.> Date: Sat, 31 Aug 2013 20:43:25 +0100
From: Emir Kotan
To: SDL Development List
Subject: Re: [SDL] SDL_image linking problem on OS X
Wow, thanks for the awesome reply. Using TCC was occasionally bugging my mind and this clarified a lot.
Fortunately, I’m not facing any of those corner cases at the moment, so I’ve happily picked Clang for the project.On 2 Sep 2013, at 09:45, Jared Maddox wrote:
Date: Sat, 31 Aug 2013 20:43:25 +0100
From: Emir Kotan <@Emir_Kotan>
To: SDL Development List
Subject: Re: [SDL] SDL_image linking problem on OS X
Message-ID: <60601E82-B4D9-45E3-A5F0-DA9D78A56A19 at gmail.com>
Content-Type: text/plain; charset=us-ascii
Is clang a better choice for C projects? I was also thinking about Tiny C
Compiler but not sure.
Not sure about Clang vs. GCC, but as far as TCC goes, it’s like this:
For most purposes you should use something other than TCC, but there
are exceptions:
Scripting: TCC has a library version of itself, which allows you to
feed C into it and get a set of functions & such out as a result. If I
remember right, it even does this on Windows 8. In comparison,
everything else you’re fairly likely to need to call on the user’s
machine, with a command-line interface, which you’ll have to parse,
etc. TCC is also somewhat simple in the library interface. Advantage:
usually TCC.
Bootstrapping: Last that I heard (and presumably the last that any
one tried, sometime within the last year I think), TCC was fully
capable of compiling GCC. Thus, if you can get TCC cross-compiled
(hopefully much simpler than with GCC), then you can move it over to
the machine that you want GCC on, and start compiling that, at which
point you should hopefully be able to further bootstrap to full
functionality.
Size: If you want to compile within limited space for some reason,
but aren’t worried about the size of the executables (let’s say that
you have some fast built-in storage, and some slow SD card storage),
then TCC is almost guaranteed to be the best option, because few, if
any, compilers are as small as TCC.
Toys: What if you want to write a VM that uses C? Do you want to
modify GCC, write your own compiler, or modify TCC? What about using
TCC from the command line like some sort of obscene version of Forth?
How about playing with Quajects as implemented in C? How about a quick
test for the validity of your C? Points 1 and 3 above both say that
you’re probably better off with TCC when you want to make a toy that
uses a compiler, than anything else.
Now, for the caveats: TCC is not a main-line production compiler, it
was never intended to be, and probably never will be. TCC performs
ALMOST (but not quite) no optimizations, so the executables produced
by any other modern compiler will likely be both faster AND smaller.
TCC is small and fast for a compiler, but this comes at the cost of
almost all optimizations. TCC is most relevant for certain corner
cases: everywhere else you should look at one of it’s competitors
first.