Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 23, 2007, 08:48 AM   #1
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Boost libraries on OS X

I thought I should try the boost libraries. So, I downloaded the source but I have a problem understanding what to do.

I have also downloaded Boost.Jam, and installed it. I ran bjam with the current directory set to the directory of the Boost source. I ran it with the command:

bjam "-sTOOLS=gcc" install

But now, where is this supposed to be installed? And how do I use the libraries with XCode?
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.
Soulstorm is offline   0 Reply With Quote
Old Mar 23, 2007, 09:51 AM   #2
wittegijt
macrumors member
 
Join Date: Feb 2007
Location: Eindhoven
Boost install in /usr/local by default. Include the necessary headerfiles. Add the library to your project and compile!

Wittegijt.
wittegijt is offline   0 Reply With Quote
Old Mar 23, 2007, 10:31 AM   #3
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Seems you have managed to do it. Can you please tell me how to include the necessary headerfiles to be installed?

Actually, it would be better to briefly tell me how you installed it in the first place. The instructions provided in the boost readme are generic, and I seem to be doing something wrong...
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.
Soulstorm is offline   0 Reply With Quote
Old Mar 23, 2007, 12:05 PM   #4
wittegijt
macrumors member
 
Join Date: Feb 2007
Location: Eindhoven
Quote:
Originally Posted by Soulstorm View Post
Seems you have managed to do it. Can you please tell me how to include the necessary headerfiles to be installed?

Actually, it would be better to briefly tell me how you installed it in the first place. The instructions provided in the boost readme are generic, and I seem to be doing something wrong...
I've installed Boost some time ago, so I don't remember exactly what I did
I just followed the instructions. Do you have the libaries installed?

#include <boost/thread/thread.hpp> (or whatever you want to use)
add /usr/local/include/boost-1_33_1 to your include search path (-I option)
add /usr/local/lib/ to your library rearch path (-L option)

Wittegijt.
wittegijt is offline   0 Reply With Quote
Old Mar 23, 2007, 01:53 PM   #5
wittegijt
macrumors member
 
Join Date: Feb 2007
Location: Eindhoven
Looking at the documentation, I probably would have used:
bjam "-sTOOLS=darwin" install
instead of gcc. Have tried that?

Witegijt.
wittegijt is offline   0 Reply With Quote
Old Mar 23, 2007, 03:11 PM   #6
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Quote:
Originally Posted by wittegijt View Post
Looking at the documentation, I probably would have used:
bjam "-sTOOLS=darwin" install
instead of gcc. Have tried that?

Witegijt.
I have tried that, but I don't think it worked. Where are the files supposed to be?


I only see this in my usr/local/ folder:



I am also attaching my terminal output. Something is missing, it seems.

I should note though, that in my boost directory, a folder was created. It's named "bin", and it has inside a folder named "boost". Inside it there are many folders containing many built libraries, dylibs for gcc and darwin. What's this? I have the feeling that everything is compiled but cannot be placed correctly.
Attached Thumbnails
Click image for larger version

Name:	Picture 2.png
Views:	18145
Size:	35.0 KB
ID:	70769  
Attached Files
File Type: zip Saved Terminal Output.txt.zip (31.8 KB, 63 views)
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.

Last edited by Soulstorm; Mar 23, 2007 at 03:19 PM.
Soulstorm is offline   0 Reply With Quote
Old Mar 27, 2007, 05:12 AM   #7
Pitfall
macrumors newbie
 
Join Date: Jul 2002
Location: Spain
You can install boost manually

Hi,

If you managed to compile the libraries (if I remember correctly they will not be universal by default) you can manually install them. I copied everything in the bin folder to /usr/local/lib. Note that I did NOT copy the directory structure, I only copied the .dilyb and .a files.

As for the headers, there should be a boost directory with headers (.h or .hpp) files, and folders for each boost library. As you can specify where XCode (or, more correctly, gcc) will look for them it is not necessary to "install" them. However I chose to copy them to /usr/local/share/boost_1.33.1.

I hope this helps.

-- EDIT --
Be sure to verify the libraries' install names (otool -L xxx.dylib, the first line is the library install name). This is important because it is the name that the loader (ld) will look for when an executable asks for the library at run time. I chose to strip any path info from the install name (consult the otool man pages) and to add /usr/local/lib to the search path.

I did this a while ago, I hope I'm being clear and that I remember correctly.

Last edited by Pitfall; Mar 27, 2007 at 05:39 AM.
Pitfall is offline   0 Reply With Quote
Old Sep 3, 2008, 03:43 AM   #8
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Just a heads up... I finally managed to do this a long time ago. I had written a tutorial on how to do this, here. I hope this proves helpful to anyone that has the same problem as me.
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.
Soulstorm is offline   0 Reply With Quote
Old Sep 3, 2008, 06:59 AM   #9
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Another easier method is to just use Mac Ports .
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Sep 3, 2008, 12:44 PM   #10
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: Austin, TX
Another easier method is to frameworktize the resulting dylibs. I got python script from the Adium SVN repository that converts dynamic libs into a framework. I have to build up a convoluted open source UPnP library (using Xcode) into a framework and that script is very handy.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   -1 Reply With Quote
Old Sep 3, 2008, 12:57 PM   #11
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by Sayer View Post
Another easier method is to frameworktize the resulting dylibs. I got python script from the Adium SVN repository that converts dynamic libs into a framework. I have to build up a convoluted open source UPnP library (using Xcode) into a framework and that script is very handy.
I've never attempted that. There are lots of useful libraries out there though that would make fantastic frameworks. May need to look into that.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Sep 3, 2008, 10:03 PM   #12
yeroen
macrumors 6502a
 
yeroen's Avatar
 
Join Date: Mar 2007
Location: Cambridge, MA
Strange, I don't remember installing boost from source being any more involved than the configure, make, make install sequence.
__________________
all Jarvis, all the time
yeroen is offline   0 Reply With Quote
Old Sep 5, 2008, 02:29 PM   #13
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Quote:
Originally Posted by yeroen View Post
Strange, I don't remember installing boost from source being any more involved than the configure, make, make install sequence.
I do, unfortunately. I wrote that guide with a help of a member from another forum, which had the exact same problem.
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.
Soulstorm is offline   0 Reply With Quote
Old Sep 5, 2008, 05:28 PM   #14
AlmostThere
macrumors 6502a
 
Join Date: Feb 2005
Location: The royal throne of kings, the sceptred isle, the other Eden, the fortress built
Quote:
Originally Posted by Soulstorm View Post
I do, unfortunately. I wrote that guide with a help of a member from another forum, which had the exact same problem.
IIRC, most of boost is implemented as header / template files and requires no linking to libraries. It's only those parts that require OS specific implementations that need linking, so you can actually use a large part of it without going through a build / install process.
__________________
Join the army of the dead: http://www.urbandead.com
AlmostThere is offline   0 Reply With Quote
Old Sep 7, 2008, 04:29 AM   #15
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Location: Menidi, Athens, Greece
Quote:
Originally Posted by AlmostThere View Post
IIRC, most of boost is implemented as header / template files and requires no linking to libraries. It's only those parts that require OS specific implementations that need linking, so you can actually use a large part of it without going through a build / install process.
I know. But for example, when I tried using boost::regex, I came into many errors, because boost::regex requires some other files in order to run. Hoever, the includes where in the type
Code:
#include <something_else.h>
and not like
Code:
#include "something_else.h"
as they should be. That caused me many errors. How am I going to get past that?
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it.
Soulstorm is offline   0 Reply With Quote
Old Mar 15, 2009, 12:51 PM   #16
noogrub
macrumors newbie
 
Join Date: Mar 2009
Mac Ports install of Boost seems not to work

Quote:
Originally Posted by Cromulent View Post
Another easier method is to just use Mac Ports :).
Hi all,
I just completed a Mac Ports install of Boost on my Mac (Leopard).

gcc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5490~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5490)

All I did was:
> sudo port install boost

It seemed successful. Took a long time, maybe 45 mins. But now when I do a simple program (first.cpp):

#include <iostream>
#include<boost/any.hpp>
int main() {
boost::any a(5);
a = 7.67;
std:cout<<boost::any_cast<double>(a)<<std::endl;
}

and then try to compile:
g++ -o first first.cpp

I get this error:
first.cpp:2:24: error: boost/any.hpp: No such file or directory
first.cpp: In function ‘int main()’:
first.cpp:4: error: ‘boost’ has not been declared
first.cpp:4: error: ‘any’ was not declared in this scope
first.cpp:4: error: expected `;' before ‘a’
first.cpp:5: error: ‘a’ was not declared in this scope
first.cpp:6: error: ‘cout’ was not declared in this scope
first.cpp:6: error: ‘boost’ has not been declared
first.cpp:6: error: ‘any_cast’ was not declared in this scope
first.cpp:6: error: expected primary-expression before ‘double’
first.cpp:6: error: expected `;' before ‘double’

Clearly, the compiler does not know where to find the new install of Boost.

I have seen several links with glib comments like "just link to this..." or "include that..", but I would deeply appreciate if someone would show me EXACTLY how that sample program should look in order to get it to properly include boost and compile.

When I do "ports info boost", I get back:
boost @1.37.0 (devel)
Variants: darwin, darwin_9, debug, docs, graphml, icu, openmpi, python24, python25, python26, st

Boost provides free portable peer-reviewed C++ libraries. The emphasis is on portable libraries which work well with the C++
Standard Library.
Homepage: http://www.boost.org

Build Dependencies: boost-jam, gmake
Library Dependencies: zlib, bzip2
Platforms: darwin
Maintainers: sancho*****gmail

I'm convinced that I am simply new and naive and am missing something so simple that an idiot should know it. If someone has successfully installed Boost using Mac Ports, please explain to me precisely why this did not work. I am really stumped. I saw the other "tutorials" but my results do not match.

The most frustrating part is not understanding how to confirm the install, other than to successfully use Boost in a program. Most tutorials say "here's what you SHOULD see" and don't delve into "here's how to figure out what is wrong if you don't".

I esp need to use boost/regex.hpp and can't simply #include<boost/regex.hpp>. It's not that easy!

Best regards, thanks in advance,
John
noogrub is offline   0 Reply With Quote
Old Mar 15, 2009, 01:12 PM   #17
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by noogrub View Post
I'm convinced that I am simply new and naive and am missing something so simple that an idiot should know it. If someone has successfully installed Boost using Mac Ports, please explain to me precisely why this did not work. I am really stumped. I saw the other "tutorials" but my results do not match.
You need to add the header and library search path options in the project settings. Set them to the appropriate folders for the boost library and header files.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Mar 15, 2009, 03:40 PM   #18
noogrub
macrumors newbie
 
Join Date: Mar 2009
Thank you for your fast reply. I supposed as much; perhaps there is a g++ config file somewhere? If there is, I don't see it, and I am not finding it by searching the web. I'm sorry to be so terribly dense, but I do not understand what you mean.

I do not have a "project". I am not programming through a GUI of any kind, and so there is no "settings" location(s). I am simply writing that sample first.cpp file in a directory under /Users/username/Documents/C_stuff using a simple text editor.

What I apparently don't know how to do is how to set g++ to know where to find the #include<boost> files. I should add that
g++ -I /path/to/boost -o outfilename file.cpp shows similar errors, but it might be because I don't understand which directory path /path/to/boost is supposed to be.

There's nothing in the world so humbling as programming.

Thanks for your patience and help.
John

Last edited by noogrub; Mar 15, 2009 at 03:42 PM. Reason: thoguht of an extra bit to add on
noogrub is offline   0 Reply With Quote
Old Mar 16, 2009, 09:00 AM   #19
noogrub
macrumors newbie
 
Join Date: Mar 2009
Solution to the #include problem for boost install on Mac Leopard

OK, I figured out how to solve part of my problem.

Using command line g++, there apparently IS no way to set a "path" except to actually explicitly declare it on the command line when compiling, using the "-I" switch.

In my case, I installed Boost using MacPorts, and it ended up in
/opt/local/var/macports/software/boost/1.37.0_0+darwin_9/opt/local/include/boost

However, putting #include<that/entire/11-step/path> into my program did not work, and using
g++ -I that/whole/path/to/boost gave a "File not found" error.

Here's the trick: back up one directory on the -I path statement, like so:
g++ -I /opt/local/var/macports/software/boost/1.37.0_0+darwin_9/opt/local/include/

(note that it looks the same, except I didn't type "boost" on the end)

My first.cpp test file (above) then compiled and ran without complaint. It works to name the directory CONTAINING the boost directory, but not the boost directory itself.

Naming an -I "starting path" for g++ means it will start looking recursively down from that starting path. Since the various boost headers all name their dependencies by saying "boost/whatever", that means if I name "boost" as the starting path, g++ is therefore directed to look in "boost/boost/whatever" and that generates the "File not found" error.

I then did this in my home directory:

ln -s /opt/local/var/macports/software/boost/1.37.0_0+darwin_9/opt/local/include/ boost

This made a symbolic link to that long directory path named simply "boost". That way, I was able to then do this:
g++ -I boost first.cpp -o first
and it compiled just fine. I moved the source file down into a sub-directory, and typed
g++ -I ../boost first.cpp -o first
and that compiled too, because g++ was able to follow the path to the symbolic link, which it could then follow to the actual boost directory.

That must seem like the stupidest most obvious thing in the world to most of you fellows. Hope that helps someone else like me sometime.

Thanks!
John
noogrub is offline   0 Reply With Quote
Old Jun 20, 2010, 11:36 AM   #20
ragzpad
macrumors newbie
 
Join Date: Jun 2010
John !!! Thanks a lot for posting the solution !! It really helped me save a couple of hours !!
ragzpad is offline   0 Reply With Quote
Old Jun 20, 2010, 02:47 PM   #21
Detrius
macrumors 68000
 
Join Date: Sep 2008
Location: Asheville, NC
That crazy long MacPorts directory can simply be reduced to "/opt/local/include". You're pointing at the uninstalled copy.



Here's what I do:

Create a folder in your home directory called "Boost." Into that directory, expand the attached zip file. Also, expand your boost tarball. Edit build_boost.sh to make sure that the boost version specified matches the version you want to build.

Run the script. It will build for OS X, iPhone, and iPhone sim. You can enable or disable portions of the script as you please. That is, just comment out the iPhone parts if you don't want to use them. Actually, building for iPhone is very slowly getting better.

Anyway, my favorite part is that when the script is done, it creates a global "BOOST" environment variable that will work in any shell for your user (log out and back in again), and it creates an additional copy that works in Xcode (quit and relaunch). Then, in Xcode, this is what my build settings look like:



OTHER_LDFLAGS = $(BOOST)/lib/libboost_system-xgcc42-mt-$(BOOST_VERSION)-macosx.a
HEADER_SEARCH_PATHS = $(inherited) $(BOOST)/include/boost-$(BOOST_VERSION)/
LIBRARY_SEARCH_PATHS = $(inherited) $(BOOST)/lib
BOOST_VERSION = 1_41



When you build this way (using the user-config.jam files), you have far more control over precisely what gets built and how, including what versions of OS X it will run on. As provided, it should build against the 10.5 SDK but still be able to run on 10.4.

I think.

YMMV.
Attached Files
File Type: zip Build_Boost.zip (3.2 KB, 131 views)
Detrius is online now   0 Reply With Quote
Old Jul 18, 2010, 07:27 PM   #22
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
Quote:
Originally Posted by Detrius View Post

...

Create a folder in your home directory called "Boost." Into that directory, expand the attached zip file. Also, expand your boost tarball. Edit build_boost.sh to make sure that the boost version specified matches the version you want to build.

Run the script. It will build for OS X, iPhone, and iPhone sim. You can enable or disable portions of the script as you please. That is, just comment out the iPhone parts if you don't want to use them. Actually, building for iPhone is very slowly getting better.

...
I'm not following this.

Lets say I have the following directory structure

Code:
MyProject/
          `-- ThirdParty/
		`-- Boost/
		     |-- Build_Boost/
		     |   |-- build_boost.sh
		     |   |-- user-config-darwin.jam
		     |   |-- user-config-iphone.jam
		     |   `-- user-config-iphonesim.jam
		     `-- boost_1_43_0/
		          `-- ...
How do you suggest I go about executing your 'build_boost.sh' so that it finds everything?

Last edited by lloyddean; Jul 18, 2010 at 10:59 PM.
lloyddean is offline   0 Reply With Quote
Old Jul 19, 2010, 10:45 PM   #23
Detrius
macrumors 68000
 
Join Date: Sep 2008
Location: Asheville, NC
The boost source directory should be in the same directory as the script. This creates a few extra directories. One is named "build." This is where the intermediates go (stuff you have no reason to keep). The other is called "installed." The libraries and the include files are all copied here. Assuming everything works, at this point, you no longer need the original boost source directory.

Like so:

Code:
MyProject/
          `-- ThirdParty/
		`-- Boost/
		     |-- Build_Boost/
		     |   |-- build_boost.sh
		     |   |-- user-config-darwin.jam
		     |   |-- user-config-iphone.jam
		     |   |-- user-config-iphonesim.jam
		     |   |-- boost_1_43_0/
                     |   |-- build/
                     |   |-- installed/
		     |   |   |-- include/
                     |   |   |-- lib/
                     `-- ...
Technically, this is independent of your single project and could potentially be used with multiple projects, so it would make more sense outside of the "MyProject" directory, but ultimately, that's just a detail.



What the script does is cd into the boost source code directory. Then it runs bjam with each of the three jam files. Each of these bjam commands culminates in installing the libraries and headers in to the "installed" directory. After all three have finished, user-wide global environment variables are set specifying for you that this is where your Boost installation is located. So far as I'm aware, this is not a Boost standard. It's just what I picked that made sense to me. There are two of these variables. One is visible in any shell. The other is visible to Xcode. Both are named "BOOST" and point to the same place for consistency, but they are technically distinct.
Detrius is online now   0 Reply With Quote
Old Jul 19, 2010, 11:30 PM   #24
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
I had all that figured out before the question. The problem is that your directions:

Quote:
Create a folder in your home directory called "Boost." Into that directory, expand the attached zip file. Also, expand your boost tarball. Edit build_boost.sh to make sure that the boost version specified matches the version you want to build.
result in the directory structure I show above - which of course doesn't work.


Finding accurate instructions for getting boost compiled and functional for iPhone development is hard to come by. Yours is the most direct and useful I've seen but could be even more useful with a slight correction.

Thank you for taking both the time and trouble to post your script and config files.

EDIT: Oh, and the reason for my placement of boost is that it follows the conventions of a former employer whose edutainment product I'm try to update and get working on the iPad. That is any dependent third party libraries must be placed within the working structure of the project for inclusion in the source control system.

Last edited by lloyddean; Jul 19, 2010 at 11:37 PM.
lloyddean is offline   0 Reply With Quote
Old Jul 21, 2010, 12:50 PM   #25
Detrius
macrumors 68000
 
Join Date: Sep 2008
Location: Asheville, NC
Does it actually work for iPhone? I've not had a chance to try it myself, but this is as far as I've been able to figure out about building it--with varying results. There are no instructions out there that I've found. I had to read the actual jam files, and they change dramatically between boost releases.

I've also done the same thing for SCM.

About the directions, I reckon I forgot that the zip expands into a directory. Oops.
Detrius is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Warcraft 3 on OS X Lion? [Help] hackdroid Mac OS X 10.7 Lion 1 Nov 18, 2011 05:59 PM
How do I control my iPod Touch on OS X through USB? (VNC) CamCracker Mac OS X 7 Sep 1, 2011 10:42 PM
Apple TV 2 & iTunes library on Time Capsule bmorris Apple TV and Home Theater 11 Mar 18, 2011 03:02 PM
C equivalent to Boost Asio? Cromulent Mac Programming 7 Nov 17, 2010 08:57 AM
OS X Boost Libraries... Help! Soulstorm Mac Programming 1 Aug 12, 2007 12:46 AM


All times are GMT -5. The time now is 10:08 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC