SFML community forums

General => General discussions => Topic started by: AndreeU17 on March 16, 2017, 08:00:52 am

Title: How to use SFML without xcode on Mac?
Post by: AndreeU17 on March 16, 2017, 08:00:52 am
I'm used to using IDEs and other software related tools. However, due to my previous computer science classes, i been enjoying using a simple text editor and a compiler.

So that been said im still relatively new to using the terminal (Mac Sierra OS).
How can i compile and link sfml to my main.cpp file?
any tips would be appreciated thanks.

I can compile a file and execute single files
g++ main.cpp -o main
./main

However, i dont know how to do it while having external Library
Title: Re: How to use SFML without xcode on Mac?
Post by: Turbine on March 16, 2017, 08:09:45 am
You could use any of these on a Mac: Codeblocks, Eclipse C++ or CLion. There's a tutorial on using SFML in Codeblocks.

Which country are you studying Computer Science in?
Title: Re: How to use SFML without xcode on Mac?
Post by: Laurent on March 16, 2017, 08:15:08 am
Quote
How can i compile and link sfml to my main.cpp file?
You can have a look at the Linux tutorial (http://www.sfml-dev.org/tutorials/2.4/start-linux.php) for that.

But this is not specific to SFML, you'll have to do the same steps for any other library that you use, so you should rather read some good tutorial about the basics of gcc.
Title: Re: How to use SFML without xcode on Mac?
Post by: AndreeU17 on March 16, 2017, 05:26:48 pm
You could use any of these on a Mac: Codeblocks, Eclipse C++ or CLion. There's a tutorial on using SFML in Codeblocks.

Which country are you studying Computer Science in?

Yeah but all those are IDEs, im trying to stay away from them. Im studying Computer Science in Portland, Oregon, USA.
Title: Re: How to use SFML without xcode on Mac?
Post by: AndreeU17 on March 16, 2017, 05:27:40 pm
Quote
How can i compile and link sfml to my main.cpp file?
You can have a look at the Linux tutorial (http://www.sfml-dev.org/tutorials/2.4/start-linux.php) for that.

But this is not specific to SFML, you'll have to do the same steps for any other library that you use, so you should rather read some good tutorial about the basics of gcc.

Yeah i know, i'd be using the gcc or g++ compiler, i was just wondering if anyone else here does it and what their tactic is for doing it.
Title: Re: How to use SFML without xcode on Mac?
Post by: Turbine on March 17, 2017, 12:10:08 am
Why are you trying to stay away from them? In professional environments nobody used CLI for a project. An IDE like Codeblocks will print the full command in the debug area, letting you see how it's compiling your project with all your libraries and so on.
Title: Re: How to use SFML without xcode on Mac?
Post by: Hiura on March 17, 2017, 09:56:29 am
There's not that much specific stuff to macOS that you need to know to make it work from the command line for basic application. It become slightly more involved if you want to create an application bundle, especially if you want to sign it, but you can find some tutorial for that, I'm sure.

Installing SFML is the same: follow the instruction at the beginning of the Xcode tutorial.

Compiling & linking your command line application is done the usual *NIX way: just `man clang` and so on to learn how. One important difference for linking though: -framework vs -l (lower case ell) (RTFM, ofc).

@Turbine: Staying away from IDE and instead use Makefile (or some similar technology) has the advantage that your project will still compile in 5+ years. Some Xcode projects can no longer be "upgraded" from old Xcode versions to newer ones. Also, vim is great!  :P

Side note: clang is now the default compiler for the C language family.
Title: Re: How to use SFML without xcode on Mac?
Post by: ToyAuthor on March 25, 2017, 02:11:35 pm
I use llvm-gcc + CodeBlocks + CMake on Mac. Xcode is not necessary.
Title: Re: How to use SFML without xcode on Mac?
Post by: Jonny on April 01, 2017, 12:36:11 pm
You can use cli or any of the various compilers on any platform. I've used both cli and xcode with SFML on macOS without any trouble (same goes for win/lin)

to answer OP, just use gcc as you would on any other unix program. Use -l command to link libraries, but I'd recommend just using CMake to generate makefiles, that way you can easily go back to the IDE if/when you need it
Title: Re: How to use SFML without xcode on Mac?
Post by: pfeilbr on July 30, 2018, 03:51:47 pm
See the following for a good example https://stackoverflow.com/questions/9054987/how-can-i-compile-sfml-project-via-command-line-on-mac (https://stackoverflow.com/questions/9054987/how-can-i-compile-sfml-project-via-command-line-on-mac)