|
|
#1 |
|
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. |
|
|
|
0
|
|
|
#2 |
|
Boost install in /usr/local by default. Include the necessary headerfiles. Add the library to your project and compile!
Wittegijt. |
|
|
|
0
|
|
|
#3 |
|
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. |
|
|
|
0
|
|
|
#4 | |
|
Quote:
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. |
||
|
|
0
|
|
|
#5 |
|
Looking at the documentation, I probably would have used:
bjam "-sTOOLS=darwin" install instead of gcc. Have tried that? Witegijt. |
|
|
|
0
|
|
|
#6 | |
|
Quote:
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.
__________________
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. |
||
|
|
0
|
|
|
#7 |
|
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. |
|
|
|
0
|
|
|
#8 |
|
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. |
|
|
|
0
|
|
|
#9 |
|
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 |
|
|
|
0
|
|
|
#10 |
|
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 |
|
|
|
-1
|
|
|
#11 | |
|
Quote:
__________________
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 |
||
|
|
0
|
|
|
#12 |
|
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 |
|
|
|
0
|
|
|
#13 |
|
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. |
|
|
|
0
|
|
|
#14 |
|
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
|
|
|
|
0
|
|
|
#15 | |
|
Quote:
Code:
#include <something_else.h> Code:
#include "something_else.h"
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it. |
||
|
|
0
|
|
|
#16 |
|
Mac Ports install of Boost seems not to work
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 |
|
|
|
0
|
|
|
#17 | |
|
Quote:
__________________
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 |
||
|
|
0
|
|
|
#18 |
|
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 |
|
|
|
0
|
|
|
#19 |
|
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 |
|
|
|
0
|
|
|
#20 |
|
John !!! Thanks a lot for posting the solution !! It really helped me save a couple of hours !!
|
|
|
|
0
|
|
|
#21 |
|
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. |
|
|
|
0
|
|
|
#22 | |
|
Quote:
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/
`-- ...
Last edited by lloyddean; Jul 18, 2010 at 10:59 PM. |
||
|
|
0
|
|
|
#23 |
|
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/
`-- ...
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. |
|
|
|
0
|
|
|
#24 | |
|
I had all that figured out before the question. The problem is that your directions:
Quote:
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. |
||
|
|
0
|
|
|
#25 |
|
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. |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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.







Linear Mode

