|
Boost Users : |
Subject: [Boost-users] Unable to use boost libraries with xcode 3.1
From: framebuffer (framebuffer_at_[hidden])
Date: 2008-12-03 23:18:55
Hi!
I am using xcode 3.1 and I am trying to build a 32bit boost test
application. I have done this successfully on windows (Header only libraries
are working fine in xcode). These are the steps I followed:
1) ./configure
--with-libraries=date_time,filesystem,iostreams,program_options,serialization,system,thread
2) sudo make install
I dont get any error and the installation says it updated all targets.
3) Next, I create a simple thread application to test:
#include <boost/thread/thread.hpp>
#include <iostream>
void hello()
{
    std::cout <<"Hello world, I'm a thread!"<< std::endl;
}
int main(int argc, char* argv[])
{
    boost::thread myThread(&hello);
    myThread.join();
    return 0;
}
4) I go to project > edit project settings and add the following two paths
in the search path section:
/usr/local/lib (for library path) and
/usr/local/include/boost-1_37 for header path.
BOOST_ROOT is set as /Users/Framebuffer/boost_1_37_0
I have even tried to change it to /usr/local/ but the errors persist
I have examined the two folders and the libraries and headers are indeed
present there (for eg, libboost_thread-xgcc40-mt-1_37.dylib is in the lib
folder)
5) When I try to compile either the debug or release version, I get errors.
Here are the errors for debug build results:
==========================================
==========================================
Building target âboostâ of project âboostâ with configuration âDebugâ â (9
errors)
    Checking Dependencies
      cd /Users/framebuffer/Desktop/boost
  /Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0 -pipe
-Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type
-Wunused-variable -D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -mfix-and-continue
-fvisibility-inlines-hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote
/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/boost-generated-files.hmap
-I/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/boost-own-target-headers.hmap
-I/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/boost-all-target-headers.hmap
-iquote
/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/boost-project-headers.hmap
-F/Users/framebuffer/Desktop/boost/build/Debug
-I/Users/framebuffer/Desktop/boost/build/Debug/include
-I/usr/local/include/boost-1_37
-I/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/DerivedSources
-c /Users/framebuffer/Desktop/boost/main.cpp -o
/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/Objects-normal/i386/main.o
      cd /Users/framebuffer/Desktop/boost
  /Developer/usr/bin/g++-4.0 -arch i386 -isysroot
/Developer/SDKs/MacOSX10.5.sdk
-L/Users/framebuffer/Desktop/boost/build/Debug
-L/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib
-F/Users/framebuffer/Desktop/boost/build/Debug -filelist
/Users/framebuffer/Desktop/boost/build/boost.build/Debug/boost.build/Objects-normal/i386/boost.LinkFileList
-mmacosx-version-min=10.5 -o
/Users/framebuffer/Desktop/boost/build/Debug/boost
Undefined symbols:
 "boost::thread::join()", referenced from:
   _main in main.o
 "boost::thread::~thread()", referenced from:
   _main in main.o
   _main in main.o
 "boost::thread_resource_error::thread_resource_error()", referenced from:
   boost::mutex::mutex()in main.o
   boost::condition_variable::condition_variable()in main.o
 "vtable for boost::detail::thread_data_base", referenced from:
   __ZTVN5boost6detail16thread_data_baseE$non_lazy_ptr in main.o
 "typeinfo for boost::thread_resource_error", referenced from:
   __ZTIN5boost21thread_resource_errorE$non_lazy_ptr in main.o
 "boost::thread::start_thread()", referenced from:
   boost::thread::thread<void (*)()>(void (*)(),
boost::disable_if<boost::is_convertible<void (*&)(),
boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)in
main.o
 "boost::detail::thread_data_base::~thread_data_base()", referenced from:
   boost::detail::thread_data<void (*)()>::~thread_data()in main.o
   boost::detail::thread_data<void (*)()>::~thread_data()in main.o
 "boost::thread_resource_error::~thread_resource_error()", referenced from:
   __ZN5boost21thread_resource_errorD1Ev$non_lazy_ptr in main.o
 "typeinfo for boost::detail::thread_data_base", referenced from:
   typeinfo for boost::detail::thread_data<void (*)()>in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
         "boost::thread::join()", referenced from:
           _main in main.o
         "boost::thread::~thread()", referenced from:
           _main in main.o
           _main in main.o
         "boost::thread_resource_error::thread_resource_error()",
referenced from:
           boost::mutex::mutex()in main.o
           boost::condition_variable::condition_variable()in
main.o
         "vtable for boost::detail::thread_data_base", referenced
from:
           __ZTVN5boost6detail16thread_data_baseE$non_lazy_ptr in
main.o
         "typeinfo for boost::thread_resource_error", referenced
from:
           __ZTIN5boost21thread_resource_errorE$non_lazy_ptr in
main.o
         "boost::thread::start_thread()", referenced from:
           boost::thread::thread<void (*)()>(void (*)(),
boost::disable_if<boost::is_convertible<void (*&)(),
boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)in
main.o
         "boost::detail::thread_data_base::~thread_data_base()",
referenced from:
           boost::detail::thread_data<void
(*)()>::~thread_data()in main.o
           boost::detail::thread_data<void
(*)()>::~thread_data()in main.o
         "boost::thread_resource_error::~thread_resource_error()",
referenced from:
           __ZN5boost21thread_resource_errorD1Ev$non_lazy_ptr in
main.o
         "typeinfo for boost::detail::thread_data_base", referenced
from:
           typeinfo for boost::detail::thread_data<void (*)()>in
main.o
        ld: symbol(s) not found
        collect2: ld returned 1 exit status
Build failed (9 errors)
==========================================
==========================================
Both files libboost_thread-xgcc40-mt-1_37.dylib and
libboost_thread-xgcc40-mt-1_37.a are present in /usr/local/lib
What am I missing? Any help will be appreciated.
ALSO, I tried to compile and run a date time example, and it seems to be
working fine. (Both debug and release) Below is the code that is working.
Other libraries like filesystem etc and not working though.
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include <iostream>
using namespace boost::gregorian;
using namespace boost::posix_time;
int main()
{
    date d(2002,Feb,1); //an arbitrary date
    ptime t1(d, hours(5)+milliseconds(100)); //date + time of day offset
    ptime t2 = t1 - minutes(4)+seconds(2);
    ptime now = second_clock::local_time(); //use the clock
    date today = now.date(); //Get the date part out of the time
    date tomorrow = today + date_duration(1);
    ptime tomorrow_start(tomorrow); //midnight
    //input streaming
    std::stringstream ss("2004-Jan-1 05:21:33.20");
    ss >> t2;
    //starting at current time iterator adds by one hour
    time_iterator titr(now,hours(1));
    for (; titr < tomorrow_start; ++titr)
    {
        std::cout << (*titr) << std::endl;
    }
    return 0;
}
I found this tutorial :
and I tried his method and its giving the same 9 errors out of the box.
Thanks,
fb.
-- View this message in context: http://www.nabble.com/Unable-to-use-boost-libraries-with-xcode-3.1-tp20827024p20827024.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net