I have a horrible time with C++ programming on Windows.
I can't link to Boost library.
Now, I am thinking about compiling my cpp programs in Ubuntu and run it on Windows.
Despite i586-mingw32msvc-g++ suggested here works for many people. It is not a good solution for me as it is older than C++11 and I cannot use it with boost library.
Is there any alternative method?
sudo apt-get install g++-mingw-w64-i686
sudo apt-get install libc6-dev-i386
Related
On Ubuntu there is a command to install boost libraries which is something like this:
sudo apt-get install libboost-all-dev
does this command also install and compile the header-only libraries?
If not, what other terminal command would I need to execute so that I can install the FULL set of boost libraries?
My ultimate aim is to know which linux terminal commands I need to install (and have available) to obtain all of the boost libraries.
As is implied by "header only", one does not need to compile the header-only libraries. They're just headers.
Now, the libbost-all-dev package does install those libraries which need compilation (in addition to the header-only libs), but it does not compile them on the spot. Ubuntu is a so-called binary distribution, which means that it distributes packages in compiled form. Apt downloads the binaries and installs them immediately. This is in contrast to e.g. Gentoo which is a source distribution (and compiles everything on your machine).
In short, no further commands are necessary. Installing libbost-all-dev will install all available Boost libraries on Ubuntu.
Your questions, as posed, makes no sense.
The Debian / Ubuntu package libboost-all-dev has dependencies, and those dependencies do include the few binary library packages (eg Boost Thread, the formatting parts of Boost DateTime, etc pp). All those will get installed.
And yes, the intent of this meta package is to install the rest of the Boost development environment.
But it does not compile anything. All Debian / Ubuntu packages are pre-generated and built-offline and "just installed" at your end.
You can inspect the content of a package by browsing the online database.
But if you are only interested in header-only libraries I suggest to download the latest version of the boost libraries right from the official website; you should also learn how to build boost from the source because it's a know-how that you are very likely to use in a near future if you are relying on that library.
An equivalent step to browsing the online database, it's about using the following command
apt-cache show <package>
so, in your case
apt-cache show libboost-all-dev
and this will give you a very specific idea about what you are about to install.
I'm not extremely familiar with the linux filesystem, having moved from windows, but I do have a decent amount of experience with C++ and the Boost libraries in windows. Having switched Fedora 17, can anyone tell me if there is a certain directory where I should install Boost to get it working the gnu compiler?
Note: if it matters, I don't use an IDE I use vim for most of my programming.
There are a few ways of setting up the boost libraries on linux.
Save yourself some pain, use your package manager to install the Boost libs. You'll be grateful in the long run.
If you absolutely must do it yourself, simply put it anywhere so long as it's in the gcc include path. This is /usr/local/include/ or /usr/include/ for headers and /usr/local/lib/ or /usr/lib/ for libraries
Finally if for some reason that isn't possible, use the -I switch with g++ to specify the path to boost. (but this would only be necessary if 1 and 2 aren't possible)
Use your package manager to install boost libraries, for debian ubuntu it is like:
sudo aptitude install libboost-system1.49.0-dev
for centos6 it is
yum install boost-devel
I had issues installing boost using yum (recently installed Fedora 17)..
so I unzipped the boost tar ball to my /opt.
so g++ -I /opt/boost/boost_1_51_0 works like a charm.
From the introduction to boost:
http://www.boost.org/doc/libs/1_51_0/more/getting_started/unix-variants.html
you can put it anywhere you like. And then you compile with something like this
c++ -I path/to/boost_1_51_0 example.cpp -o example \
-L~/boost/stage/lib/ -lboost_regex-gcc34-mt-d-1_36
"c++" can be g++ or clang++ for example.
In Ubuntu, there is a package called uuid-dev. To install and use it, I just need to run apt-get install uuid-dev. However, in MinGW, I couldn't install this package using mingw-get install.
May I know what are the basic steps to port a C++ application/library from Ubuntu to MinGW?
It might already support compilation under MinGW. Generally you would download the source, unpack them and run ./configure and see what happens.
Give that a try and get back to me.
I am not familiar with the usual build technique in linux I am using boost c++ library. Can any body guide me in installing and configuring boost c++ library. Thanks in advance
My environment is Linux Fedora 15. On it, one can easily install boost by typing,
$ yum install boost-devel
After installation, you'll find boost under /usr/include/boost/.
However, if you run,
$yum install boost
you'll only find .so of boost under /usr/lib/, like /usr/lib/libboost_timer.so.1.48.0.
It's OK if you're not familiar with the usual build technique because Boost doesn't use the usual build technique. Follow the instructions in the "getting started" documentation. Make sure you read all the way to the bottom of the page. The link to the Unix-specific instructions is at the very, very bottom.
For most parts of Boost, installation is synonymous with unpacking the tarball into your preferred include directory. Other parts of Boost require compilation, so go to the Boost installation directory, run ./bootstrap.sh, and then run ./bjam install.
depending on the Linux distribution you are using, you'll probably find boost is already built and packaged for you, e.g. on Fedora "yum install boost"
Rob Kennedy's answer is still valid except that is recommended now to install with ./b2 instead of ./bjam.
I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?
I don't have Windows, so it would be really cool, if I could do that on Linux :)
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32, for example.
Ubuntu, for example, has MinGW in its repositories:
$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]
Suggested method gave me error on Ubuntu 16.04: E: Unable to locate package mingw32
===========================================================================
To install this package on Ubuntu please use following:
sudo apt-get install mingw-w64
After install you can use it:
x86_64-w64-mingw32-g++
Please note!
For 64-bit use: x86_64-w64-mingw32-g++
For 32-bit use: i686-w64-mingw32-g++
One option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.
To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32
To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp
You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.
To install wine, run:
sudo apt-get install wine
Install a cross compiler, like mingw64 from your package manager.
Then compile in the following way: instead of simply calling gcc call i686-w64-mingw32-gcc for 32-bit Windows or x86_64-w64-mingw32-gcc" for 64-bit Windows. I would also use the --static option, as the target system may not have all the libraries.
If you want to compile other language, like Fortran, replace -gcc with -gfortran in the previous commands.
I've used mingw on Linux to make Windows executables in C, I suspect C++ would work as well.
I have a project, ELLCC, that packages clang and other things as a cross compiler tool chain. I use it to compile clang (C++), binutils, and GDB for Windows. Follow the download link at ellcc.org for pre-compiled binaries for several Linux hosts.
From: https://fedoraproject.org/wiki/MinGW/Tutorial
As of Fedora 17 it is possible to easily build (cross-compile) binaries for the win32 and win64 targets. This is realized using the mingw-w64 toolchain: http://mingw-w64.sf.net/. Using this toolchain allows you to build binaries for the following programming languages: C, C++, Objective-C, Objective-C++ and Fortran.
"Tips and tricks for using the Windows cross-compiler": https://fedoraproject.org/wiki/MinGW/Tips
For Fedora:
# Fedora 18 or greater
sudo dnf group install "MinGW cross-compiler"
# Or (not recommended, because of its deprecation)
sudo yum groupinstall -y "MinGW cross-compiler"