Installing boost in debian (for Codeblocks) - c++

I'm currently working on a project that I've been assigned. I'm going to program a gateway (also known as a router). I have a virtual setup with 3 virtual machines (3 debian 7.1 devices).
The first one represents the gateway (the router) and the two other represents two clients (computers) who are going to transmit information between each other, through the gateway. The two clients have static IP's for the virtual representation.
I have installed Code::Blocks for Debian on the gateway, and I'm planning to program this all in C++ (or C). I have not made up my mind entirely, but I plan to use C++ as for now.
I've searched around a little to find out how to create sockets in C++ so I can start getting a grip on stuff and start looking on some packets which I will send from Client1. There's a lot of different libraries it seems, but Boost is pretty much preferred as far as I've found. I can't quite get a grip on how to install boost for Debian and use it in code blocks, so if someone could explain it low tech wise for me..?
I've downloaded the most recent version of Boost and extracted it somewhere on the gateway. How do I install it and make it work for Codeblocks?
Thanks!

Integrating Boost in to Code::Blocks is beyond my ken, but here is how I acquire and install Boost under linux. This is particularly for version 1.54.0, but you can adjust for whatever version you prefer:
mkdir -p ~/dev/boost
cd ~/dev/boost
wget http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz
tar -zxf boost_1_54_0.tar.gz
cd boost_1_54_0
sudo ./bootstrap.sh
sudo ./b2 install
sudo ln -s /usr/local/include/boost_1_54_0/ /usr/local/include/boost

http://tuxarena.blogspot.in/2009/01/how-to-compile-and-install-codeblocks.html
The above link would be helpful.
Thanks & Regards,
Alok Thaker

Related

How to install dependencies for a project that is being cross-compiled on an x86 host for an arm target

I'm trying to build a project (https://wpewebkit.org/) on Debian Buster for armv7 on a x86 host of the same OS.
I am able to successfully install an arm C++ toolchain and I can successfully compile and run trivial applications.
Where I'm stuck is many of the projects I want to compile require many dependencies that I normally install through the OS's package manager (ex apt-get install libjpeg-dev). When cross compiling, it looks like I can just download & make install the sources I need. However, this project has hundreds of dependencies - it would take a long time to download and compile all of them. At the same time, the arm versions of these dependencies already exist in apt for arm.
How can I, on the host system, install the armhf versions of these dependencies and make them available to my cross compiling toolchain? I've tried dpkg add-architecture armhf and then installing via apt-get install libjpeg-dev:armhf but cmake can't seem to find the installed dependencies.
#artless-noise guides were a good jumping off point, but unfortunately most of the guides weren't helpful in accomplishing what I wanted to do (or if they were, they weren't straightforward in explaining how to accomplish what I needed).
What I ended up doing was using qemu-debootstrap
sudo qemu-debootstrap --arch armhf buster /mnt/data/armhf http://deb.debian.org/debian/
And then just using sudo chroot /mnt/data/armhf and I had a functioning shell where I could just apt-get anything I needed, run any scripts and get armhf binaries.
There are many ways to do this. The key concept is that you need a shadow filesystem that mimics the ARM and you need to tell the package build mechanism where they are. There are many distributions variants LTIB is rpm based, Yocto uses BitBake and supports deb, rpm and ipkg. As well you need to differentiate between build tools and deployed binaries. This is an added concept when cross compiling. The only point above is that Ltib, Yocto, buildroot, etc all keep a shadow root files system and some place to keep host/build binaries. Since you have a Debian system, it is best to stick to their tools.
It is possible to install with dpkg --root. And if you have a complete environment, you can chroot arm_root and then build the package there with host binaries but ARM development files (headers and libraries).
The Debian maint-guide is an overview of building debian packages for the normal case. The Debian cross-compile wiki uses the chroot methods and has reference to building with either sbuild or pbuild packages. The schroot package is very nice as it allows you to build the shadow file system without becoming root. It is very easy to destroy your host file system when learning to cross distribution build and I highly recommend this method. Another key difference between the maint-guide and cross wiki is to install the package cross build essentials.
sudo apt-get install build-essential crossbuild-essential-armhf
Otherwise, most everything is the same but building with the chroot shadow ARM filesystem.
Here is a translation for Ubuntu hosts... you need Zenial or better to use the cross-compile debian wiki method. Ie, a Ubuntu x86 Bionic build for raspberry PI or similar. This method takes care of a lot of things for you, especially preventing filesystem corruption by mistake; thank the kind souls at Debian.
The info under nomenclature is quite important,
build means the architecture of the chroot/dpkg/compiler's executable, i.e. the architecture of the build system (called host by cmake/kernel/etc)
host means the architecture of produced executable objects, i.e. the architecture of the host system where these guest objects will run on (called target or sometimes build elsewhere)
target is what the produced executable objects will generate when producing executable objects, i.e. the architecture of the systems the built programs target their results to run on (relevant only for compilers and similar)
People change the names for the same concepts in cross-building and that can be confusing.
Additional info
Kernel cross build
Meson Cross Compilation
Clang cross compile

C and C++ Cross Compiling from Arch Linux to Windows

I can't install mingw-w64-gcc in Arch linux, so i can't compile my .cpp files for Windows...
I have aldready tried wineg++, but it isn't good for me...
Anyone can help me?
Thanks
Assuming that what you want is to install mingw-w64-gcc in Arch, the steps you need to do are:
1) go to: https://aur.archlinux.org/packages/mingw-w64-gcc/ and download a snapshot (on the upper right side of the web page).
2) decompress the file with tar xzvf /your_path/mingw-w64-gcc.tar.gz.
3) install the package. cd mingw-w64-gcc/ && makepkg -si.
You may need to install other dependencies from the Arch User Repository (AUR).
Hope you find this helpful.
For future questions related with Arch Linux issues I would recommend you first to search in the Arch Wiki, and if you cannot find a solution, then use the Arch forums.
PS: Let me also suggest you to use Docker for making your code executable anywhere. It's quite simple to use when you learn it.

Specify which version to install with macports

I would like to install a specific version of gdb and gcc with macports on mac os x leopard, not the last one, but the 6.8 for gdb. Is it possible?
It is possible. It's just convoluted and tedious. It's listed in the documentation these days.
Steps
Go to macports trac and find the package you're looking for. This is the link for subversion, which is the package I'll be using in the example.
Click the PortFile
Click Revision Log (top right)
Pour through the revisions until you find the version you're looking for. Remember the revision number.
In this example I'm looking for version 1.7 of subversion.
With that revision number noted. You need to checkout the version of that subdirectory at that revision.
cd /tmp
svn co http://svn.macports.org/repository/macports/trunk/dports/devel/subversion --revision 106629
Then cd into the folder and run the install
cd subversion
sudo port install
Then it should become selected by default. You can check with
sudo port installed subversion
The following ports are currently installed:
subversion #1.7.10_0 (active)
subversion #1.8.8_0
subversion #1.8.10_0
As I just came across this question when trying to figure out how to download an older version of curl, I thought I'd share an update:
The currently accepted answer did not work for me any longer. This is with MacPorts 2.2.0. What I did was the following.
I started following the directions located here. I ended up using the SVN method, since the first method didn't work. What I didn't realize is that I was missing a critical step.
I found another post that suggested moving the downloaded directory to /private/tmp. After doing this, I cd into the new directory and after a sudo port install I was able to install the older version.
I am on a Mac running OS X 10.8, so your mileage may vary.
This post is old.. but specifying a version is possible. For example I want to install ZeroMQ version 3.2.2 so I use:
sudo port install zmq #3.2.2
And it always helps to goto the MacPorts website and search to see if they have what you are looking for.
As far as I know it is not possible at all to install other versions than the exact version, unless there is a specific port for a certain version.
The only thing you could do is fetch the portfile of the desired version from the Macports subversion repository.
In your case only gdb 7.2 is available on the current version, no variants and no other versions - sorry :)

learning c++ on linux mint ( for .net developer )

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.

Enabling OpenGL in wxWidgets

I installed the wxWidgets source code, compiled it and am linking the libraries thus obtained with my application code. Now I need to use OpenGL in my wxWidgets application. How do I enable this?
For building on Windows with project files:
Assume $(WXWIDGETSROOT) is the root directory of your wxWidgets installation.
Open the file $(WXWIDGETSROOT)\include\wx\msw\setup.h
Search for the #define for wxUSE_GLCANVAS.
Change its value from 0 to 1.
Recompile the library.
For building on Linux and other ./configure based platforms:
Just use ./configure --with-opengl
(A mashup answer from two partial answers given by others)
If you're using configure to build wxWidgets you just need to add --with-opengl to your command line.
Just to add a little bit... If you're on linux you need to watch the logs when running configure. If it can't find opengl dev packages then it will turn opengl off with one line of warning which is easy to miss.
run it like this to make it more obvious what development libraries you're actually missing (it looks like the --with-opengl is on by default in 3.0.0 and possibly earlier versions of wxwidgets, but it can't hurt to include it I suspect).
./configure --with-opengl > configure.log
Once configure can find all the dev libs you think you're going to use you need to rebuild wxwidgets:
make
sudo make install
I had to install these on linux mint to make wxwidget's configure happy as far as opengl was concerned (and should also work for ubuntu) to get the dev libs I needed.
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
(Assume $(WX_WIDGETS_ROOT) is the root directory of your wxWidgets installation.)
Open the file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h
Search and find the option wxUSE_GLCANVAS. Change its value from 0 to 1.
Recompile the library.