Crystal build fails with linker error - crystal-lang

I've just tried to run the simple HTTP server from the language documentation. The program fails with an error.
/usr/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc -o "/home/rasmus/dev/crystal/projects/hello/.crystal/crystal-run-hello.tmp" "${#}" -rdynamic -lssl -levent -lrt -lpcl -lpcre -lgc -lpthread -ldl`
The program has been copy-pasted from the documentation.
I can confirm that the program did/does run on my guest machine, but not on my host. Both are Ubuntu 14.04.3 installs.

The problem was simply that the SSL libraries weren't installed. If you have the same problem you can simply run sudo apt-get install libssl-dev. This should install everything needed to fix the error.

Related

Crystal build fails with error - cannot find -levent

I was getting this error while trying to run a simple crystal program in my ubuntu.
/usr/bin/ld: cannot find -levent (this usually means you need to install the development package for libevent)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: cc "${#}" -o /home/xyz/.cache/crystal/crystal-run-test.tmp -rdynamic -L/home/xyz/.asdf/installs/crystal/1.1.1/bin/../lib/crystal/lib -lpcre -lm -lgc -lpthread -levent -lrt -ldl
Issue has been solved by installing libevent packages by running the following command:
sudo apt-get install libevent-dev

ld configuration cannot find -lboost_system

I already installed libboost, and I made sure the certain library already located in /usr/lib/x86_64-linux-gnu/. I already called #include <boost/filesystem.hpp> in my .cpp file. But, whenever I run this,
g++ -Wall -g -o result.out main.cpp -L/usr/lib/x86_64-linux-gnu -lboost_system
The system gave me
/usr/bin/x86_64-linux-gnu-ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
Realizing it mentioned ld, I checked my /etc/ld.so.conf.d, and I found a configuration file linked to /usr/lib/x86_64-linux-gnu/. I ran sudo ldconfig, then ran the g++ command again, same result.
I don't know what I'm going to do next, so can anyone help me? I'll provide another information related to this if anyone ask. Thanks in advance.

SDL library error: cannot find -lSDL_ttf cannot find -lSDL_image

I'm running a C++ program using sdl, my ubuntu version is 16.04.
After I sudo apt-get install libsdl1.2-dev and run the following displays :
g++ sdl-config --cflags -g -W -Wall -Weffc++ -Wextra -pedantic -O0 main.cpp -o run generateFrames.o sdl-config --libs -lSDL_ttf -lSDL_image
/usr/bin/ld: cannot find -lSDL_ttf
/usr/bin/ld: cannot find -lSDL_image
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'run' failed
make: *** [run] Error 1
How to get rid of this error ?
You only installed SDL library. SDL_image and SDL_ttf are different libraries. You can download them via sudo apt-get install libsdl-image1.2-dev libsdl-ttf2.0-dev. There is also another popular SDL extension SDL_mixer: libsdl-mixer1.2-dev

/usr/bin/ld: cannot find -lGL (Ubuntu 14.04)

I'm trying to build a project created in QT Creator and unfortunately every time I try to compile I get an error. Here is my compiler output:
23:02:20: Running steps for project WallpaperAppQt...
23:02:20: Configuration unchanged, skipping qmake step.
23:02:20: Starting: "/usr/bin/make"
g++ -m64 -o WallpaperAppQt main.o mainwindow.o moc_mainwindow.o -L/usr/X11R6/lib64 -lQt5Widgets -L/usr/lib/x86_64-linux-gnu -lQt5Gui -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [WallpaperAppQt] Error 1
23:02:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project WallpaperAppQt (kit: Desktop)
When executing step 'Make'
23:02:20: Elapsed time: 00:00.
You need a package that provides the libGL.so (no version suffix) symlink. In Ubuntu, it's in the libgl1-mesa-dev package. So just do:
sudo apt install libgl1-mesa-dev
I was able to fix my problem by following the instructions in this link:
http://techtidings.blogspot.com/2012/01/problem-with-libglso-on-64-bit-ubuntu.html
(the final two commands)
sudo rm /usr/lib/x86_64-linux-gnu/libGL.so
sudo ln -s /usr/lib/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so
I was having the same problem. Then I used the following command in the terminal:
sudo apt install mesa-common-dev libglu1-mesa-dev"
and the application run perfectly.
It's obvious that ld doesn't find lib GL in default library path which should be include /lib* /usr/lib*. You should install library GL or tell g++ where lib GL was installed with cmd args -L if that was installed already.

gcc: cannot find -lasound when crosscompiling

I try to crosscompile this small program to my arm device, but get error:
arm-none-linux-gnueabi/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
Then i found libasound files in my target device and have copied to my folder /usr/lib but still no effect.
I use the commands:
export CFLAGS="-I/usr/include -I/usr/lib"
$CC -o play sound_playback.c $CFLAGS -lasound
I have installed libasound2-dev package on my Ubuntu 14.04 x64 and be able to compile the program on my native computer without any errors.
UPDATE WITH SOLUTION
As Marc and John have said below, i just should use -L flag to set my library path. So my command line should be:
$CC -o play sound_playback.c $CFLAGS -L/usr/lib -lasound