Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Are there any user friendly tools out there to cross-compile from Windows to Linux?
crosstool-ng supports building cross-compilers with cygwin host.
Overview:
Install cygwin, with development packages
Download crosstool-ng
Extract the tarball (tar xvjf crosstool-ng*)
Run ./configure
When configure complains about a missing tool, go back to cygwin setup and install the corresponding package (e.g. flex, libtool, ncurses-devel) You'll need at least the following:
Devel/gperf
Devel/bison
Devel/byacc
Devel/wget
Devel/patch
Devel/make (GNU version)
Devel/automake 1.10+
Libs/libncursesw10
Libs/libncursesw10-devel
make
make install
Create a new directory for building the cross-compiler, e.g. /usr/src/cross-linux-gnu-root
Enable system-wide case sensitivity support in the registry (see https://superuser.com/questions/266110/how-do-you-make-windows-7-fully-case-sensitive-with-respect-to-the-filesystem#answer-842670)
Mount the directory case-sensitive (e.g. mount c:/cygwin/usr/src/cross-linux-gnu-root /usr/src/cross-linux-gnu -o binary,posix=1)
From inside the cross-compiler build directory, ct-ng menuconfig
In the menus, set target architecture to x86 (probably) and subarchitecture to i686 (avoids GCC 4.8 issues, thanks osm0sis), target kernel to linux, and target C library to glibc, and enable the C++ compiler.
To work around make 4.0 issues, also enable EXPERIMENTAL in Paths and misc options then, go in Companion tools (at top-level) and enable Build some companion tools and then make 3.81 (Thanks osm0sis)
wget has issues with the latest kernel.org certificates so use the .wgetrc method in this accepted answer: How do I fix certificate errors when running wget on an HTTPS URL in Cygwin? (Thanks osm0sis)
Currently 3 file patches are required to avoid further errors:
the _libintl_gettext error as mentioned in the comments
the byteshift headers, and
the ELF headers (Thanks Duncan Calvert & osm0sis)
ct-ng build
Of course, this is NOT going to enable you to build linux applications from inside Visual Studio. (VS2010 and later let you build with other toolchains such as gcc, but you'd need an appropriate toolchain description in addition to the cross-compiler built by crosstool-ng). But you'll have a working g++-linux-gnu, which you can either run directly or using a Makefile.
NOTE: Building the cross-compiler takes a LONG time. osm0sis has provided a prebuilt gcc 4.8.1 here, along with his notes on building the cross-compiler (used to update this answer).
Your best bet is to use a cross platform IDE like Code::Blocks that can import MSVC projects, and generate a Makefile for Linux, which you can then run on a Linux (with even the same program if you so wish).
So your work flow would then look something like the following:
Code, Compile, and debug on MSVC -> import into Code::Blocks & generate Makefile
-> test compile and debug with GCC
-> copy to Linux with Code::Blocks -> test compile & debug on Linux
It's a little obtuse, probably, but at least Code::Blocks takes care of a lot of those small details with things like Makefiles, and what not.
Compile to Linux from Windows without to use virtualization or cross compiler but only natively via CoLinux. Create native Linux executable files without leave (reboot) windows. C/C++ Compiling for Linux under Windows through Cooperative Linux. The fastest switching between Windows and Linux through Alt+Tab (no restarting or rebooting needed):
Install CoLinux
Use CoLinux root file system image: Ubuntu-9.04-1gb.7z
Start CoLinux
Change string archive.ubuntu.com to old-releases.ubuntu.com with:
$ sudo vi /etc/apt/sources.list
Update your configuration:
$ sudo apt-get update
Install two software packages to be able to compile your programs (c/c++, gcc compilers, mysql dev 5.1):
$ sudo apt-get install build-essential
$ sudo apt-get install libmysqlclient15-dev
Accessing Windows directories from CoLinux:
$ mount cofs0 /mnt/ -t cofs
$ cd /mnt
Compile
$ c++ your.source.cc -o executable.name
Are you asking for something that can take code written to run on Windows and make it run on linux? There's not really a compiler that does that - but maybe you're looking for Wine ( http://www.winehq.org/ ) which lets you run Windows apps on linux (if they use APIs Wine has thunked out).
Edit: I'm assuming your code is using Windows APIs (Win32, etc.) in this answer. If you're only using Standard C++ and libraries available cross-platform, then there's lots of other answers.
I don't believe there are any compilers that allow you to compile on Windows and then take the resulting binary and run it on a Linux machine. Your best bet is to set up two development environments, one on Windows and one on Linux. Do most of your development and debugging in the Windows environment if that's what suits you, then frequently compile and test under Linux to be sure your code is truly cross-platform. You'll also want to use a cross-platform build system and testing framework. I recommend using cmake and Google Test, respectively.
Related
I have an application that I built using Qt Creator on Linux and want to deploy it now. However, I don't want to statically build it as I don't want it to be open-sourced. I tried the ldd ./YourExecutable command, however that only lists (and not add) the additional dependencies the application needs in order for it to run. My question is, how do I gather the necessary dependencies without having to individually look for these files? Is there a tool, such as windeployqt.exe on Windows, that I can use on Linux for the same purpose? Or is there a better approach than the one I'm thinking of?
Get Cygwin setup.exe: http://www.cygwin.com/
1.1. Run setup.exe and continue to package selection list.
1.2. Under Devel catagory select tools you need for compiling your source. For
example 'GNU make'.
1.3. Finish installing.
Get linux crosscompilers for cygwin:
"cygwin-gcc-linux.tar.bz2" (68.2 Mb).
md5sum: 340e91a346f5bb17e660db10e43005b8
These compilers are made with crosstool 0.28-rc37. This package contains:
gcc-3.3.4 and gcc-2.95.3 for i386 (glibc 2.1.3) and gcc-3.3.3 for amd64
(glibc 2.3.2).
Note! There is now newer version of GCC avaible with glibc 2.3.2:
"cygwin-gcc-3.3.6-glibc-2.3.2-linux.tar.bz2 (i386, x86_64)".
2.1. Copy 'cygwin-gcc-linux.tar.bz2' to 'c:\cygwin' or install directory which
you selected in setup.exe.
2.2. Open Cygwin shell and change directory to root with 'cd /'.
2.3. Uncompress to Cygwin root with command:
'tar -jxvf cygwin-gcc-linux.tar.bz2'.
Cross-compilers are installed under '/opt/crosstool'. You can use theim
directly or with commands: gcc-linux, g++-linux, gcc-linux-2.95,
g++-linux-2.95, gcc-linux-x86_64 and g++-linux-x86_64.
From: Cross-compiling on Windows for Linux
More info here.
It sounds like you want to use the shared library deployment option:
http://doc.qt.io/qt-5/linux-deployment.html#creating-the-application-package
Then if you wanted to go further than that, you could look into making a .rpm or a .deb .
There are lots of examples of qt projects that are now available on GitHub and have packages made. Usually for prebuilt binaries you need to make one for x86 and a separate one for x64.
Hope that helps.
I am interested in taking my C++ program and cross compiling it into something that can run on an ARM MCU. To do this, I am required to have gcc-arm-none-eabi installed. I'm currently on a Windows 7 machine, and so I have installed GCC/make/g++/etc. via MinGW.
From the research I've done, it seems that MinGW does not support this toolchain, which leads me to believe that Windows-based ARM development isn't possible. So I ask: how does one use MinGW to install the gcc-arm-none-eabi toolchain locally?
You can use MinGW for this; you just need to swap out the C++ toolchain for your chosen one. You can still invoke it from the MSYS console, and all your other tools will still work. There's nothing inherent to MinGW or MSYS that makes this "not supported".
Personally I install GCC 4.9 gcc-arm-none-eabi from launchpad.net, mount the toolchain's directory in MSYS then export the paths I need:
mount 'C:\PROGRA~2\GNUTOO~1\4947E~1.920' /foo
mount 'C:\PROGRA~2\GNUTOO~1\4947E~1.920\ARM-NO~1' /foo_local
To discover the short name for the paths, write dir /X at the Windows command prompt. On my machine, the paths above are equivalent to the following, respectively:
C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2014q4
C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2014q4\arm-none-eabi
The mounting only needs to be done once; the export directives may be added to /etc/profile:
export CPPFLAGS="-I/foo_local/include"
export CFLAGS="-I/foo_local/include"
export CXXFLAGS="-I/foo_local/include"
export LDFLAGS="-L/foo_local/lib -mthreads"
export PATH=".:/foo_local/bin:/foo/bin:/bin:/opt/bin"
Then just run g++.
Or of course you can skip all the export business and just invoke your chosen GCC directly:
/foo/bin/g++
If you're using MSYS2, MinGW compliance, you'll be able to install arm-none-eabi-gcc through pacman
You can download it from here: https://www.msys2.org
Follow the instructions to properly setup the environments.
Then use this commands below
pacman -S mingw-w64-x86_64-arm-none-eabi-gcc mingw-w64-x86_64-libwinpthread-git
now you'll also need to add this into PATH,
echo "export PATH=$PATH:/mingw64/bin" >> ~/.bashrc
source ~/.bashrc
Then, you can now call arm-none-eabi-gcc with the MSYS2 shell.
See here for the details of this package https://packages.msys2.org/group/mingw-w64-x86_64-arm-none-eabi-toolchain
ELLCC is another option. You don't necessarily need mingw or mingw-64 installed to run it since it is statically linked. This post talks about using it to target Windows, but the same binary can also be used to target ARM and other processors. It's based on clang/LLVM though, not gcc.
I want to compile C++ code on MacOS X, using the g++ compiler. How do I install it?
That's the compiler that comes with Apple's XCode tools package. They've hacked on it a little, but basically it's just g++.
You can download XCode for free (well, mostly, you do have to sign up to become an ADC member, but that's free too) here: http://developer.apple.com/technology/xcode.html
Edit 2013-01-25: This answer was correct in 2010. It needs an update.
While XCode tools still has a command-line C++ compiler, In recent versions of OS X (I think 10.7 and later) have switched to clang/llvm (mostly because Apple wants all the benefits of Open Source without having to contribute back and clang is BSD licensed). Secondly, I think all you have to do to install XCode is to download it from the App store. I'm pretty sure it's free there.
So, in order to get g++ you'll have to use something like homebrew (seemingly the current way to install Open Source software on the Mac (though homebrew has a lot of caveats surrounding installing gcc using it)), fink (basically Debian's apt system for OS X/Darwin), or MacPorts (Basically, OpenBSDs ports system for OS X/Darwin) to get it.
Fink definitely has the right packages. On 2016-12-26, it had gcc 5 and gcc 6 packages.
I'm less familiar with how MacPorts works, though some initial cursory investigation indicates they have the relevant packages as well.
Installing XCode requires:
Enrolling on the Apple website (not fun)
Downloading a 4.7G installer
To install g++ *WITHOUT* having to download the MASSIVE 4.7G xCode install, try this package:
https://github.com/kennethreitz/osx-gcc-installer
The DMG files linked on that page are ~270M and much quicker to install. This was perfect for me, getting homebrew up and running with a minimum of hassle.
The github project itself is basically a script that repackages just the critical chunks of xCode for distribution. In order to run that script and build the DMG files, you'd need to already have an XCode install, which would kind of defeat the point, so the pre-built DMG files are hosted on the project page.
Type g++(or make) on terminal.
This will prompt for you to install the developer tools, if they are missing.
Also the size will be very less when compared to xcode
Download Xcode, which is free with an ADC online membership (also free):
http://developer.apple.com/technology/xcode.html
xcode is now available for free from the app store. Just "buy it" (for free) and it will download. To get the command line tools go into preferences/downloads and "install command line compiler tools".
Instead of gcc you are using clang, but it works the same.
Here is how to do it on the newer mac chips and how to switch from clang(default) to g++
Install g++ through home-brew.
Check out the version you just installed, probably 12th or higher
You can make a symbolic link from g++-12 to g++
In order to do it, just type in your terminal:
sudo ln -s $(which g++-12) /usr/local/bin/g++.
Now open a new terminal and check your version again and you should see g++ instead of clang
g++ --version
My goal is to hop on to C++ programming language by doing a homework project on linux mint and learn some linux & c++ at the same time.
I intend to write a small desktop application to show current network traffic ( like DU meter in windows). I have following questions:
I noticed in mint there is an application called 'System Monitor' which also shows network history with info and graph like current download/upload of data and speed. Is it a good idea to get started by looking at the code for this ? how can I find the code for same in mint and dig into it ? pls help with some steps here if possible.
what tools do I need here for writing c++ application for/in linux mint ?
Which GUI library to use ( like in c# winforms , it offers user controls as part of GDI lib) on linux mint what do we have that offers user controls like window/button/panel/etc ?
Links to beginner level tutorials will be helpful.
Hoping NOT to re-invent the wheel completely here. Would love to re-use some lib that do the network traffic part, ideas ?
PS: i know this post reads 'wanna be' - I am really excited to kickstart with some c++. Will rephrase this post with more precise questions.Hunting in the dark at this point being a c# developer totally spoiled by windows.
Thanks in Advance!!! for tips on this...
The mint distribution is based on Ubuntu/Debian, so I assume that my Ubuntu approach also works on mint.
First
you need some tools, libraries and headers:
# install the standard toolchain (g++, make, etc.)
sudo aptitude install build-essential
# install the build dependencies for a desktop based networking tool
sudo aptitude build-dep gnome-nettool
Optionally
because you mentioned the system-monitor - it might be helpful to build the gnome-system-monitor from source:
# install the build dependencies for gnome-system-monitor
sudo aptitude build-dep gnome-system-monitor
# get the sources for the gnome-system-monitor
mkdir example
cd example
apt-get source gnome-system-monitor
# build the gnome-system-monitor
# note: you might have a different version. But I'm sure you get the idea ;-)
cd gnome-system-monitor-2.28.0
sh configure
make
Finally
you need something to develop and debug. A lot of unix developers recommend emacs or vi(m). But my personal opinion is that you should start with a "modern" GUI based IDE.
here's a collection of some commonly used IDEs:
Eclipse with CDT
NetBeans
Code::Blocks
Anjuta (was this used to develop the gnome-system-monitor ?)
CodeLite (which is my personal favorite)
see also: discussion on SOF regarding "the best" C++ IDE for Linux
People usually use text editors like (g)Vim or emacs to write C++ applications. If you've never seen them before they may be a bit overwhelming. You can also use IDEs like Geany, Anjuta, QtCreator, Eclipse...
I think the default desktop environment in Mint is GNOME which uses the GTK library. You could use GTK for your application. It is written in C but there is a c++ interface for it, gtkmm, and a tutorial for it on the projects site.
There is also Qt, which is the base of the K Desktop Environment or KDE. It is a very large library and has a pretty good IDE written in it, for it, QtCreator.
Finally, you should search stackoverflow because most of your questions have already been answered.
In answer to you "what tools do I need", you should at a minimum install g++, the standard C++ compiler on a GNU/Linux system.
Linux Mint is based on Ubuntu (which is in turn based on Debian), so for a binary like gnome-system-monitor, the command
apt-get source $(dpkg -S $(which gnome-system-monitor) | cut -d: -f1)
will download and unpack the source package for it in the current directory. Note that it probably depends on a number of libraries, that can be found in different packages. You can see what these are with apt-cache show package_name, and libraries often have associated development packages named with -dev that contain the associated headers and statically-linked archives. You can find the dev package names by searching using apt-cache search foo, where foo is the base name of the library package you're interested in.
I am new to both Qt and Linux C++ development (although I have many years C and C++ development experience on Windows).
I have some legacy C projects (source files and headers - [not using Qt]) that I want to compile into shared libs on Linux.
I am proposing to store my projects under the following structure:
/home/username/Projects/project_name
/home/username/Projects/project_name/src
/home/username/Projects/project_name/build
Can anyone tell me how to do the following (using Qt to simplify the build process)
Create different build configurations (debug, release etc)
Build a configuration to create the appropriate shared library
As an aside, I have only recently installed Ubuntu 9.10 and the only C/C++ development tool I have installed (using SPM) in Qt - so I dont know if I need to install some other GNU C++ tools.
BTW I have already checked and have gcc (v4.4.1) available on my machine. I do not appear to have g++ though - I do not know whether this is significant or not.
An Ubuntu system doesn't come with build tool chain by default. Instead it has a meta package that you will need to install:
sudo apt-get install build-essential
This will install, among other the g++ compiler, although I am not sure about the Qt headers an such. For them you will need the qt4-dev package (I assume you wish to work with qt4 rather then qt3).
As for the bould structure, you will want to consult the qmake manual, or you might want to consider using CMake (apt-get install cmake) instead. CMake allow for out of build sources, as you require, and personally, I can't recommend it enough.