SFML community forums
General => General discussions => Topic started by: declan on May 31, 2010, 10:58:45 pm
-
Hi everyone! Sorry if this should be in another forum, feel free to move it if it is.
Anyway, I need to do some simple graphics with C++. I don't need a GUI, just a simple display like one could do with Java's Swing or AWT packages. It'll basically involve taking some data and drawing a bunch of different colored rectangles. Nothing dynamic or interactive with the user.
First of all, is SFML something I should be using then?
Also, I am on Mac OS X. From the webpage, it had the tutorial using Xcode. I don't use Xcode nor do I want to start (actually, if I had my way, I wouldn't be using a Mac, I'd be using a PC with Linux. But this is a lab computer). I currently just use vi and g++ for coding. Can I just use SFML without Xcode?
Thanks!
-
1 - Yes.
2 - Probably. From my understanding, vi isn't a full IDE and you must be compiling on the command line? If so just look up how to link to libraries with g++. If vi is a full IDE, replace 'g++' in my last sentence with 'vi' :lol:
I hope that's all right. I don't know much about macs.
Isn't Swing/AWT a full GUI package?
-
Haha yeah, vi is a text editor, the lightest one you can think of, runs in the terminal.
So I tried running the sample program given in the linux tutorial on the webpage. It said it couldn't find the file included. Ok, so I found where it was in the filesystem, and made sure it would be included with the -I option of g++ and its path. No dice, still couldn't find it...
I'm going to try on my home computer right now in linux, see if it works.
-
I can't really help with using g++ from the command line, sorry. I have done it before but always end up using Code::Blocks. Why not try C::B on your mac?
-
Well, got it working on my own computer, so it can't be too much harder in OS X.
-
Short answer : Yes, you can.
The main difference of GCC/G++ on linux and OSX is the linking part. On OSX you use frameworks => -l becomes -framework, If I'm right.
I don't remember all the details but I had done this before for a really trivial code using SFML. (But I was using VIM :P )
Have fun!
-
Well, I was wrong. Despite it being easy as hell in Linux, it's still tricky in OSX. So I'm trying to just first do g++ -c clock.cpp (where clock.cpp is the sample program they gave in the Linux tutorial, here: http://www.sfml-dev.org/tutorials/1.6/start-linux.php ).
It is saying that SFML/System.hpp can't be found. So, I made a directory in /usr/include/c++/4.0.0/ (since this was one location of iostream, for example, meaning that g++ probably looked here for included files) called SFML, and copied System.hpp into there. Now it can find System.hpp, but System.hpp can't find all its .hpp buddies it depends on. Am I going to have to copy every goddamn .hpp file to there?
I know there's an easier way. Can anyone shed some light on this? God, I hate Macs.
-
You should use the -I option.
Check out "man g++".
-
If you had looked a little bit more at the installation tutorial for Mac OS X, you wouldn't have got into all these troubles.
Follow what's explained for the installation and it'll work (you just don't have to install the Xcode templates as you're not using Xcode). Otherwise everything has been said (there is no include option needed, and you replace -llib_name with -framework framework_name for the linking step).
Don't blame Mac OS X for being tricky if you are new to this OS and don't even read the tutorial.
-
If you had looked a little bit more at the installation tutorial for Mac OS X, you wouldn't have got into all these troubles.
Follow what's explained for the installation and it'll work (you just don't have to install the Xcode templates as you're not using Xcode). Otherwise everything has been said (there is no include option needed, and you replace -llib_name with -framework framework_name for the linking step).
Don't blame Mac OS X for being tricky if you are new to this OS and don't even read the tutorial.
I did read the Mac tutorial. I did copy what I was told to for 64 bit OSX.
What do you mean by "there is no include option needed" ? As in, I don't need the line #include <SFML/System.hpp> ?
And my framework_name, you mean the equivalent of lib_name (so sfml-graphics for example) ?
-
If you had looked a little bit more at the installation tutorial for Mac OS X, you wouldn't have got into all these troubles.
Follow what's explained for the installation and it'll work (you just don't have to install the Xcode templates as you're not using Xcode). Otherwise everything has been said (there is no include option needed, and you replace -llib_name with -framework framework_name for the linking step).
Don't blame Mac OS X for being tricky if you are new to this OS and don't even read the tutorial.
I did read the Mac tutorial. I did copy what I was told to for 64 bit OSX.
What do you mean by "there is no include option needed" ? As in, I don't need the line #include <SFML/System.hpp> ?
And my framework_name, you mean the equivalent of lib_name (so sfml-graphics for example) ?
There is no include option needed with the g++ (the -I option). The SFML #include are still required.
Yup, for example you would compile your program with "g++ -o clock clock.cpp -framework sfml-system".
Edit : and I was saying you didn't follow the tutorial because you got an error with <SFML/System.hpp> not being found, which means the SFML framework were not installed. Thus you got into the Linux installations steps, said it was complicated for nothing, even if here was only a little point missing.
-
If you had looked a little bit more at the installation tutorial for Mac OS X, you wouldn't have got into all these troubles.
Follow what's explained for the installation and it'll work (you just don't have to install the Xcode templates as you're not using Xcode). Otherwise everything has been said (there is no include option needed, and you replace -llib_name with -framework framework_name for the linking step).
Don't blame Mac OS X for being tricky if you are new to this OS and don't even read the tutorial.
I did read the Mac tutorial. I did copy what I was told to for 64 bit OSX.
What do you mean by "there is no include option needed" ? As in, I don't need the line #include <SFML/System.hpp> ?
And my framework_name, you mean the equivalent of lib_name (so sfml-graphics for example) ?
There is no include option needed with the g++ (the -I option). The SFML #include are still required.
Yup, for example you would compile your program with "g++ -o clock clock.cpp -framework sfml-system".
Edit : and I was saying you didn't follow the tutorial because you got an error with <SFML/System.hpp> not being found, which means the SFML framework were not installed.
Well, I'm pretty confused. I followed exactly what it said for a 64 bit OS. Here's what I have right now:
mayer:~ declan$ ls /Library/Frameworks/
AVEngine.framework MacRuby.framework
AquaTerm.framework MacScanner.framework
HPDeviceModel.framework ScanBooster.framework
HPPml.framework VirusScanPreferences.framework
HPServicesInterface.framework lib64
HPSmartPrint.framework x86_64
mayer:~ declan$ ls /Library/Frameworks/lib64/
SFML.framework sfml-graphics.framework sfml-system.framework
sfml-audio.framework sfml-network.framework sfml-window.framework
mayer:~ declan$ ls /Library/Frameworks/x86_64/
sndfile.framework
I tried doing exactly what you said, no -I option and such:
mayer:trash declan$ g++ -o clockrun clock.cpp -framework sfml-system
clock.cpp:1:27: error: SFML/System.hpp: No such file or directory
clock.cpp: In function ‘int main()’:
clock.cpp:6: error: ‘sf’ has not been declared
clock.cpp:6: error: ‘Clock’ was not declared in this scope
clock.cpp:6: error: expected `;' before ‘Clock’
clock.cpp:10: error: ‘sf’ has not been declared
clock.cpp:10: error: ‘Sleep’ was not declared in this scope
And just to be thorough, here's clock.cpp:
1 #include <SFML/System.hpp>
2 #include <iostream>
3
4 int main()
5 {
6 sf::Clock Clock;
7 while (Clock.GetElapsedTime() < 5.f)
8 {
9 std::cout << Clock.GetElapsedTime() << std::endl;
10 sf::Sleep(0.5f);
11 }
12
13 return 0;
14 }
15
(ignore the line numbers, they're copied out of vim).
Am I missing something very obvious?[/code]
-
Am I missing something very obvious?
Yup you are :D .
Once you've downloaded and installed the files on your hard drive, copy the contents of the SFML-x.y/lib directory (or lib64 if you use the 64 bits version) into the /Library/Frameworks directory. Then go to the SFML-x.y/extlibs/bin directory. For the 32 bits version, copy the OpenAL.framework and libsndfile.framework directories to /Library/Frameworks. For the 64 bits version, only copy the contents of the x86_64 directory. The minimal installation is finished.
-
Well, I feel like an idiot. It works now. Thanks!