Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to use SFML without xcode on Mac?  (Read 14806 times)

0 Members and 1 Guest are viewing this topic.

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
How to use SFML without xcode on Mac?
« 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

Turbine

  • Full Member
  • ***
  • Posts: 100
    • View Profile
Re: How to use SFML without xcode on Mac?
« Reply #1 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?
« Last Edit: March 16, 2017, 08:11:31 am by Turbine »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to use SFML without xcode on Mac?
« Reply #2 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 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.
Laurent Gomila - SFML developer

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: How to use SFML without xcode on Mac?
« Reply #3 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.

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: How to use SFML without xcode on Mac?
« Reply #4 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 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.

Turbine

  • Full Member
  • ***
  • Posts: 100
    • View Profile
Re: How to use SFML without xcode on Mac?
« Reply #5 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.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: How to use SFML without xcode on Mac?
« Reply #6 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.
SFML / OS X developer

ToyAuthor

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: How to use SFML without xcode on Mac?
« Reply #7 on: March 25, 2017, 02:11:35 pm »
I use llvm-gcc + CodeBlocks + CMake on Mac. Xcode is not necessary.

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: How to use SFML without xcode on Mac?
« Reply #8 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

pfeilbr

  • Newbie
  • *
  • Posts: 1
    • View Profile