Papierkorb / qt5.cr

Qt5 bindings for Crystal, based on Bindgen
Mozilla Public License 2.0
211 stars 20 forks source link

clang: error: no such file or directory: '/lib/qt5/src/qt5/../../ext/binding.a' #3

Closed hanyuone closed 4 years ago

hanyuone commented 7 years ago

I'm trying to run a sample project using qt5.cr:

require "qt5"

# Create the application first
qApp = Qt::Application.new

# We'll use a normal widget as window
window = Qt::Widget.new
window.window_title = "Hello, World!"

# We need to give it a layout
layout = Qt::VBoxLayout.new
window.layout = layout

# Create a label and a button, and push it into the layout
button = Qt::PushButton.new "Click me!"
label = Qt::Label.new "Click the button!"

layout << button << label

# On every press on `button`, we want to change the label.
counter = 0

button.on_pressed do # This is how you connect to the `pressed` signal
  counter += 1
  label.text = "You pressed #{counter} times!"
end

# We're ready for showtime
window.show

# And now, start it!
Qt::Application.exec

When I do crystal src/crystal_qt5.cr (crystal_qt5 is the name of my project), I get an error:

clang: error: no such file or directory: '.../lib/qt5/src/qt5/../../ext/binding.a'
Error: execution of command failed with code: 1: `cc "${@}" -o '.../.cache/crystal/crystal-run-crystal_qt5.tmp'  -rdynamic  .../lib/qt5/src/qt5/../../ext/binding.a -lstdc++ -lQt5Core -lQt5Gui -lQt5Widgets -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.23.1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`

I have Qt5 installed on my MacBook, which is running Mac OS X.

(... is my user configuration stuff, which is omitted.)

Papierkorb commented 7 years ago
  1. Retry with the master-ready-to-use branch if you're on master.
  2. There's no support for Mac right now (yet?). As I don't own a Mac, I can't test it on that platform.

If you are however on the master-ready-to-use branch, make sure you're using the latest version. If so, try running make in the ext/ directory. This is done by the postinstall script of qt5.cr, but it's targeted at Linux machines only right now.

hanyuone commented 7 years ago

I'm on the master-ready-to-use branch right now. Qt5 works fine with the Qt Creator, I'm not sure if I've installed anything incorrectly or not, I followed all the instructions on the Qt page when installing for Mac OS X.

Running make in ext/ results in this:

cc -c -o qt_binding.o qt_binding.cpp -fPIC -fno-rtti -I/usr/include/qt -I.
qt_binding.cpp:9:10: fatal error: 'QtCore/QtCore' file not found
#include <QtCore/QtCore>
         ^
1 error generated.
make: *** [qt_binding.o] Error 1
Papierkorb commented 7 years ago

Yep, path issue. I can't fix it as I don't have a Mac. Someone with an affinity to Mac OS machines would have to take over Maintainership for Mac-specific things.

ShalokShalom commented 7 years ago

Sadly, there is no good macOS emulation, as far as I am aware.

faustinoaq commented 7 years ago

I use Manjaro and this project works very well, even in other Linux distros.

I don't have a mac, so I can't test it on OSX

I think I can create a OSX VM on VirtualBox (I know is quite illegal but hey I don't have a Mac 😅 )

x86128 commented 6 years ago

I know that it's strange, but have this issue on Ubuntu 16.04 LTS (Qt 5.5). Tried to compile sample on two fresh installs in qemu and my host system, and got same error:

cc: error: /mnt/2TB/projects/lb-projects/qqq/lib/qt5/src/qt5/binding/../../../ext/binding_linux-gnu-x86_64-qt5.5.a: No such file or directory
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/strike/.cache/crystal/crystal-run-qqq.tmp'  -rdynamic  /mnt/2TB/projects/lb-projects/qqq/lib/qt5/src/qt5/binding/../../../ext/binding_linux-gnu-x86_64-qt5.5.a -lstdc++ -lQt5Core -lQt5Gui -lQt5Widgets -lpcre -lgc -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

ls -la in lib/qt5/ext/:

$ ls -la 
total 10224
drwxrwxr-x 1 strike strike     546 Feb 19 16:28 .
drwxrwxr-x 1 strike strike     264 Feb 19 16:24 ..
-rw-rw-r-- 1 strike strike      35 Dec 26 23:57 .gitignore
-rw-rw-r-- 1 strike strike     416 Dec 26 23:57 Makefile
-rw-rw-r-- 1 strike strike    3785 Dec 26 23:57 bindgen_helper.hpp
-rw-rw-r-- 1 strike strike    2565 Dec 26 23:57 converters.hpp
-rw-rw-r-- 1 strike strike 1744387 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.10.cpp
-rw-rw-r-- 1 strike strike 1739876 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.5.cpp
-rw-rw-r-- 1 strike strike 1744614 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.6.cpp
-rw-rw-r-- 1 strike strike 1736471 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.7.cpp
-rw-rw-r-- 1 strike strike 1740045 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.8.cpp
-rw-rw-r-- 1 strike strike 1742412 Dec 26 23:57 qt_binding_linux-gnu-x86_64-qt5.9.cpp

make in lib/qt5/ext gives:

$ make
make: *** No rule to make target 'qt_binding_.o', needed by 'binding_.a'.  Stop.

when I subst a "linux-gnu-x86_64-qt5.5" in Makefile in BINDING_PLATFORM because I've have qt5.5 installed, it make gives:

BINDING_PLATFORM=linux-gnu-x86_64-qt5.5 make
cc -std=c++11 -c -o qt_binding_linux-gnu-x86_64-qt5.5.o qt_binding_linux-gnu-x86_64-qt5.5.cpp -Wall -Werror -Wno-unused-function -fPIC -fno-rtti -I -I.
In file included from qt_binding_linux-gnu-x86_64-qt5.5.cpp:2:0:
converters.hpp:1:31: fatal error: gc/gc.h: No such file or directory
compilation terminated.
Makefile:20: recipe for target 'qt_binding_linux-gnu-x86_64-qt5.5.o' failed
make: *** [qt_binding_linux-gnu-x86_64-qt5.5.o] Error 1

Is there any "refernce" build system for this lib? C++ Qt samples builds normal.

Papierkorb commented 6 years ago

converters.hpp:1:31: fatal error: gc/gc.h: No such file or directory

You're missing libgc-dev. If something else is also missing, check https://github.com/Papierkorb/bindgen/blob/master/ci/install_debian.sh#L28 for reference

x86128 commented 6 years ago

Thanks, I've got "Hello from Crystal/Qt"! :smile: Need to add libgc-dev to Ubuntu deps on README page (May be some build checker for Qt and GC libs)

docelic commented 4 years ago

Closing this ticket under the assumption that the errors originally reported were indeed stemming from missing libgc-dev package. The note of needing to install it has since been added to bindgen.