Find the answer to your Linux question:
Results 1 to 4 of 4
I'm new to Linux. Under Windows, I use Visual C++ to build my app with boost libraries. However under Ubuntu, I got some problems. I did some google search and ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3

    How to link to all boost library by command line ?

    I'm new to Linux. Under Windows, I use Visual C++ to build my app with boost libraries. However under Ubuntu, I got some problems. I did some google search and I find out that to link a specific library, for example :
    Code:
    #include <boost/thread/thread.hpp>
    #include <iostream>
    #include <boost/array.hpp>
    #include <boost/regex.hpp>
    
    void hello()
    {
    	std::cout << "Hello world, I'm a thread!" << std::endl;
    }
    
    int main(int argc, char* argv[])
    {
    	boost::array< int, 4 > ary;
    
    	boost::thread thrd( &hello );
    	thrd.join();
    	return 0;
    }
    On terminal I use this :
    g++ ex1.cpp -o ex1 -lboost_thread
    It worked, but I want a more general way to handle this. How could I link all my libraries so that I don't have to remember all the -lboost_...
    Or could anyone show me a makefile use to compile C++ with boost libraries.
    Any help or suggestion would be appreciated. Thanks everybody !

  2. #2
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    #makefile

    all:
    g++ ex1.cpp -o ex1 -lboost_thread
    clean:
    rm ex1
    then put that in the same directory as your source file, and type make.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3
    - Thanks meton_magis. I'm really frustrated with boost-library. I used openGL, gtk+ and gktmm...without any difficulty of compilation and installation. But with boost, I couldn't find a way to get through it. I did a lot of google search but I never find a tutorial show how to install boost and build boost( even boost.org ), the way they describe is hard to understand and follow. For example, some of the examples I got compiled, some didn't.
    - Could you show me how to install boost 1.37.0 from scratch ? I really want to learn boost but I always get trouble installing and compiling it.

  4. #4
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    I have no idea how you would do that. I would suggest using your distrobution's package manager to find and install it.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...