I need to compile/link 32 bit and 64 bit C/C++ executables on Ubuntu 16.04 (64 bit). I executed the following commandlines:

sudo apt-get install build-essential
sudo apt-get install automake libtool libtool-bin
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install lib32ncurses5 lib32z1
sudo apt-get install gcc-multilib g++-multilib 
sudo apt-get install libglib2.0-dev 

The last command will install 64 bit glib2.0 library

But when I try to install the 32 bit glib2.0 library via command:

sudo apt-get install libglib2.0-dev:i386

It uninstalls the 64 bit glib2.0 library I just installed earlier (as noted by the remove comment after issuing the 32 bit install):

dev@ubuntu:~$ sudo apt-get install libglib2.0-dev:i386
[sudo] password for dev: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
libltdl-dev:i386 libltdl7:i386 libpcre3-dev libpcre32-3 libpcrecpp0v5 libxext-dev:i386 libxext6:i386
libxfixes-dev:i386 libxfixes3:i386 libxi6:i386 libxtst6:i386 odbcinst1debian2:i386 zlib1g-dev
Use 'sudo apt autoremove' to remove them.
Suggested packages:
The following packages will be REMOVED:
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 1 to remove and 15 not upgraded.
Need to get 0 B/1,422 kB of archives.
After this operation, 1,367 kB disk space will be freed.
Do you want to continue? [Y/n]  

Could someone tell me how can I prevent the removal of 64 bit glib2.0 libraries (as well as other libraries I may install) when installing its 32 bit version on Ubuntu 16.04. I need both 32 bit and 64 bit libraries installed for my C/C++ build.

As noted by the list of commands I executed, I did add 32 bit architecture to my 64 bit Ubuntu and verified that it is being recognized by the OS:

dev@ubuntu:~$ dpkg --print-architecture
dev@ubuntu:~$ dpkg --print-foreign-architectures

So based on the above query, there should be no reason why I can't have a glib2.0 library that is 64 bit and 32 bit (or for any library that has both 64/32 bit libraries available) installed in the same 64-bit OS, right? At least this is what the debian multiarch link tells me.

If so, where am I going wrong here, that the package manager is disallowing this? Multiarch, is support on Ubuntu 16.04, right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.