Trying to compile GTK application for 32bit linux from 64bit linux - linux

I am trying to compile a GTK application for 32bit linux from 64bit linux.
When I run this command:
gcc main.c -m32 -mms-bitfields -o output/main `pkg-config --cflags --libs gtk+-3.0` && ./output/main
I get these errors:
/usr/bin/ld: cannot find -lgtk-3
/usr/bin/ld: cannot find -lgdk-3
/usr/bin/ld: cannot find -latk-1.0
/usr/bin/ld: cannot find -lgio-2.0
/usr/bin/ld: cannot find -lpangocairo-1.0
/usr/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/ld: cannot find -lcairo-gobject
/usr/bin/ld: cannot find -lpango-1.0
/usr/bin/ld: cannot find -lcairo
/usr/bin/ld: cannot find -lgobject-2.0
/usr/bin/ld: cannot find -lglib-2.0
collect2: error: ld returned 1 exit status
Running Linux Mint 17.2 Rafaela.
I have all the required packages and I've even included the -m32 option but it still doesnt work.
There is also a similar question here which doesn't have an accepted answer.
Edit:
The accepted answer below suggested I install the 32bit version of libgtk-3-dev. I could not do this without removing important system packages. In the end I resorted to simply using a 32bit linux distro with the 32bit version of libgtk-3-dev installed.

You could run:
apt-get install libgtk-3-dev:i386
then rerun your compile command and it should work. If the above command returns an error saying it cannot find the package specified, you may need to run this, then try again:
dpkg --add-architecture i386
Warning: If the command above asks you to remove packages, read the list carefully, if the list includes important system packages or if you are unsure then do not proceed.

Related

/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtCore.so when searching for -lQtCore

When I try to build a new project using Qt Creator, I get these errors:
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtGui.so when searching for -lQtGui
/usr/bin/ld: cannot find -lQtGui
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libQtCore.so when searching for -lQtCore
/usr/bin/ld: cannot find -lQtCore
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.a when searching for -lpthread
collect2: error: ld returned 1 exit status
make: *** [untitled] Error 1
This is the command line from Compile Output:
g++ -m32 -o untitled main.o mainwindow.o moc_mainwindow.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
It seems it is trying to build in 32-bit mode even though I'm on Ubuntu 64-bit.
I found the problem - my Qt Kits were all wrong. I had reinstalled Ubuntu recently, switching from 32-bit to 64-bit, but I had preserved my home folder, and I had a stale configuration at ~/.config/QtProject/. Deleting that folder fixed my problem and now Qt Creator builds projects fine.

Compiling for 32 bit on a 64 bit DMD

I am using xubuntu 16.04 amd64, and use the D Language. I used to use DMD i386 on a 32 bit machine (ubuntu 14.04), but now, for some reason, I can't (or don't want to) install DMD_i386 on my system, so I installed the one for amd64. All of my projects were written on a 32 bit machine, and I used the int type instead of the long type that's available on 64bit. Now whenever I try to compile something that I wrote earlier, that looks something like this, gives an error;
void someFunction(){
string[] someArray;
uint ln = someArray.length;//This compiled perfectly on 32 bit, but now it says that someArray.length is ulong, and ln is uint.
}
I know that changing ln's type to ulong will fx it, but I wan't to compile this for 32 bit, and not 64 bit, and on 32 bit, the long/ulong type isn't available, since it uses 64 bits.
What I've tried:
I've tried using the -m32 switch to make DMD produce 32 bit output. The error mentioned above is fixed by this, but a linker (ld) error shows up:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
How do I get DMD to produce 32 bit output on a 64 bit DMD?
Solved the problem myself. Turns out, I was missing some packages needed by the linker. This solved the problem:
sudo apt install gcc-multilib

Linking error: DSO missing from command line

I am rather new to Linux (using Ubuntu 14.04 LTS 64bit), coming from Windows, and am attempting to port over an existing CUDA project of mine.
When linking via
/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart
I encounter the following error:
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to symbol 'XConvertSelection'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [CUDANN] Error 1
The answer seems closely related to the solutions in this post (Strange linking error: DSO missing from command line), though given my inexperience with Linux I was unable to adapt them to my own problem.
Any ideas on what the problem could be?
Here is the full output during compilation: https://gist.github.com/wbolden/857eddd11e4dcb915c02
And here is my attempt at a Makefile:
https://gist.github.com/wbolden/135033daae04ed0d8cf3
Hopefully this will be of help to those, like me, who are new to Linux and don't find anything related to Linux to be particularly obvious.
As noted by talonmies, I am not able to link indirectly and as such need to specify any additional libraries required by the libraries I am using. That is to say, if I link library A, which requires libraries B and C, I need to link all three libraries for the program to link correctly.
To find what other libraries were needed I used the pkg-config command, for which I found a guide here. Running pkg-config --print-requires --print-requires-private glfw3 gave the following output, which is the list of packages required by glfw3.
x11
xrandr
xi
xxf86vm
gl
I was then able to find what libraries I needed to include by running pkg-config --libs, followed by the name of the library. For example, pkg-config --libs x11 yielded -lX11.
Note: you can pass multiple items to pkg-config as input, so running
pkg-config --libs $(pkg-config --print-requires --print-requires-private glfw3)
will print out all the additional libraries you need to link (-lX11 -lXrandr -lXi -lXxf86vm -lGL).
My program now links successfully, I hope this helpful to anyone with a similar problem.
Your linker need X11 library,You need to specify -lX11 to linker
Try
/usr/local/cuda/bin/nvcc -arch=compute_30 -code=sm_30,compute_30 -o Main.o Display.o FileUtil.o Timer.o NeuralNetwork.o -L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda/lib64 -lGLEW -lglfw3 -lGL -lGLU -lcuda -lcudart -lX11
Try to add -pthread at the end of the library list (command line) in the Makefile.
It worked for me.
Use the following commands to fix the issue:
FLAGS=-lX11 ./configure --prefix=/usr --disable-static
make
make install

using gcc -m32 flag cannot find -lgcc and -lgcc_s

I'm trying to compile a 32 bit assembly code(NASM) on my 64 bit Linux, but I can't, I have tried others tutorials about it and I installed ia32-libs...
When I try run it as:
gcc asm1.o -o asm1
i386 of the file input `asm1.o' is incompatible with the output i386:x86-64
And when I try run it as:
gcc -m32 asm1.o -o asm1
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: connot find -lgcc_s
collect2: error: ld returned 1 exit status
Thanks for helps.
OBS: Sorry for my english, I'm not from US.
Need to install gcc-multilib.

Problems when build Skia on linux

Please help me about problems when i try build Skia by this guide
It said that:
/usr/bin/ld: cannot find -lfreetype
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lGLU
/usr/bin/ld: cannot find -lX11
Thank's so much!
/usr/bin/ld is the linker: it links the program you are trying to compile with existing libraries. In your case, those libraries will be files named libfreetype.so, libfontconfig.so, and so on.
The problem in your case is probably those libraries don't exist on your system. So you must install them. The process for doing so varies depending on which version of Linux you are running.
On a Redhat, CentOS or Fedora based system, the process would be to do something like
yum -y install "*freetype*"
Look at the output of 'yum list' to find the exact name. If you're on another type of Linux, perhaps someone else can help.

Resources