I'm running on 64-bit Ubuntu, and trying to get DMD v2.052 to work with Code::Blocks. The problem is, Code::Blocks does compiling and linking in two separate steps, and I can't seem to get around that. My compiler flags (for this project) are -m64, and my linker flags are all the ones supplied in dmd.conf. However, I get errors when I try to do this, like
Linking console executable: bin/Debug/Gossamer
/usr/bin/ld: skipping incompatible /home/me/devl/sfml2/bindings/d/lib/libdsfml-system.a when searching for -ldsfml-system
/usr/bin/ld: cannot find -ldsfml-system
/usr/bin/ld: skipping incompatible /home/me/devl/sfml2/bindings/d/lib/libdsfml-graphics.a when searching for -ldsfml-graphics
/usr/bin/ld: cannot find -ldsfml-graphics
/usr/bin/ld: skipping incompatible /home/me/devl/sfml2/bindings/d/lib/libdsfml-audio.a when searching for -ldsfml-audio
/usr/bin/ld: cannot find -ldsfml-audio
/usr/bin/ld: skipping incompatible /home/me/devl/sfml2/bindings/d/lib/libdsfml-window.a when searching for -ldsfml-window
/usr/bin/ld: cannot find -ldsfml-window
collect2: ld returned 1 exit status
I compiled the DSFML libs myself, using dmd -m64 -lib [library source code files], and there it wasn't in two steps, so I know they're fine. It seems ld doesn't like them, for some reason. Can somebody help?
Try doing the compile from the command line using just DMD. If that works I think there is a flag that will cause DMD to print the command line for the link command. From that you should be able to tell what you need Code::Blocks to do differently.
Related
I'm trying to develop a small utility using the dialog library in C (the dialog command in linux).
On fedora linux works fine, but if i try to compile it on debian with the command:
gcc -ldialog -lncurses -I/usr/include dialog_test.c
I get the following error:
vetinari#ankhmorpork:~/Projects/Other/test$ gcc -ldialog -I/usr/include dialog_test.c
/usr/bin/ld: /tmp/ccX6fPYB.o: warning: relocation against `dialog_vars' in read-only section `.text'
/usr/bin/ld: /tmp/ccX6fPYB.o: in function `main':
dialog_test.c:(.text+0x5c): undefined reference to `init_dialog'
/usr/bin/ld: dialog_test.c:(.text+0x79): undefined reference to `dialog_yesno'
/usr/bin/ld: dialog_test.c:(.text+0xae): undefined reference to `dialog_menu'
/usr/bin/ld: dialog_test.c:(.text+0xbc): undefined reference to `dialog_vars'
/usr/bin/ld: dialog_test.c:(.text+0xc5): undefined reference to `end_dialog'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
The dialog command works fine.
Anyone has any idea why it isn't working on debian?
(Answer for the wiki sake, in case someone comes by here later)
You have to put the libraries you want to link at the end of the gcc command, like this:
gcc dialog_test.c -ldialog -lncurses
The reason is explained here: The way the linker looks up symbols it has to first see the reference, and then the library prodiving the symbol
Additionally, the dialog library might have other dependencies than ncurses. There is explanation how to find out what to include and what to link here, in short: dialog-config should tell you about it.
In this specific case, what worked for me (ubuntu 20.04) was linking ncursesw instead of ncurses.
After that, I was left with an
undefined reference to `sqrt'
linker error, which can be solved by linking the match library using -lm.
So, in total, this command works:
gcc dialog_test.c -ldialog -lncursesw -lm
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.
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
I try to learn how to use realityGrid so I use cmake to build some samples. After finishing use ccmake command, I tried to use make command. But I'm keeping to get the errors:
/usr/bin/ld: cannot find -lvtkCommon
/usr/bin/ld: cannot find -lvtkFiltering
/usr/bin/ld: cannot find -lvtkGraphics
/usr/bin/ld: cannot find -lvtkImaging
/usr/bin/ld: cannot find -lvtkIO
/usr/bin/ld: cannot find -lvtkRendering
I found the libvtkCommon.a in /usr/lib/vtk-5.10. What should I do? Thanks ahead.
you should install the package containing the "vtk" libraries so ld can find them.
if you installed them manually you need to add the path at which those files are located to the library path configuration.
http://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html
You need to tell CMake that you require the VTK module. I haven't used CMake much, but I believe the line you need is something like:
find_package(VTK REQUIRED NO_MODULE)
include(${VTK_USE_FILE})
If that doesn't work, you could probably fall back to something like this:
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/lib/vtk-5.10)
The bad part about the last line is that it won't port well to other environments where the version is slightly different.
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.