madmonkey1907/hakchi

Cannot compile fel_lib.c

Closed this issue · 8 comments

On macOS 10.12.2, running make halts after an error while trying to compile fel_lib.c after it was patched:

clang -c -pipe -mmacosx-version-min=10.7 -I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 -std=gnu99 -DNDEBUG -Wall -Wextra -Wno-error -O2 -arch x86_64 -Wall -W -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++ -I../hakchi-gui -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/include -I../3rdparty/sunxi-tools -I../3rdparty/sunxi-tools/include -I../3rdparty/mkbootimg -I. -I. -I../hakchi-gui -I. -F/usr/local/Cellar/qt/4.8.7_2/lib -o fel_lib.o ../3rdparty/sunxi-tools/fel_lib.c
../3rdparty/sunxi-tools/fel_lib.c:65:3: error: void function 'no_usb_error' should not return a value [-Wreturn-type]
                exit(exitcode);
                ^~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:49:29: note: expanded from macro 'exit'
#define exit(x) {no_exit(x);return 0;}
                            ^      ~
../3rdparty/sunxi-tools/fel_lib.c:98:4: error: void function 'usb_bulk_send' should not return a value [-Wreturn-type]
                        usb_error(rc, "usb_bulk_send()", 2);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:67:55: note: expanded from macro 'usb_error'
#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}
                                                      ^      ~
../3rdparty/sunxi-tools/fel_lib.c:114:4: error: void function 'usb_bulk_recv' should not return a value [-Wreturn-type]
                        usb_error(rc, "usb_bulk_recv()", 2);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:67:55: note: expanded from macro 'usb_error'
#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}
                                                      ^      ~
../3rdparty/sunxi-tools/fel_lib.c:499:3: error: void function 'feldev_claim' should not return a value [-Wreturn-type]
                usb_error(rc, "libusb_claim_interface()", 1);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:67:55: note: expanded from macro 'usb_error'
#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}
                                                      ^      ~
../3rdparty/sunxi-tools/fel_lib.c:503:3: error: void function 'feldev_claim' should not return a value [-Wreturn-type]
                usb_error(rc, "FAILED to get FEL mode endpoint addresses!", 1);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:67:55: note: expanded from macro 'usb_error'
#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}
                                                      ^      ~
../3rdparty/sunxi-tools/fel_lib.c:615:3: error: void function 'feldev_init' should not return a value [-Wreturn-type]
                usb_error(rc, "libusb_init()", 1);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../3rdparty/sunxi-tools/fel_lib.c:67:55: note: expanded from macro 'usb_error'
#define usb_error(x,y,z) {no_usb_error(x,y,z);if(z!=0)return 0;}
                                                      ^      ~
6 errors generated.
make[1]: *** [fel_lib.o] Error 1
make: *** [build/hakchi-gui] Error 2

add -Wno-return-type at line 13 in the *.pro file (QMAKE_CFLAGS)

Thanks for the quick reply.

I just tried this, and I did try something similar earlier on the same line (-Wno-return-type -Wno-implicit-int), but either way, fel.cpp then fails to compile:

clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 -Wall -Wextra -O2 -arch x86_64 -Wall -W -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++ -I../hakchi-gui -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/include -I../3rdparty/sunxi-tools -I../3rdparty/sunxi-tools/include -I../3rdparty/mkbootimg -I. -I. -I../hakchi-gui -I. -F/usr/local/Cellar/qt/4.8.7_2/lib -o fel.o ../hakchi-gui/src/fel.cpp
../hakchi-gui/src/fel.cpp:16:9: error: use of undeclared identifier 'free'
        free(pointer);
        ^
../hakchi-gui/src/fel.cpp:105:30: warning: implicit conversion from 'unsigned long' to 'int' changes value from 18446744073709551488 to -128
      [-Wconstant-conversion]
    if(!force)emit dataFlow(0-sizeof(buf));
                   ~~~~~~~~ ~^~~~~~~~~~~~
../hakchi-gui/src/fel.cpp:175:24: warning: implicit conversion from 'unsigned long' to 'int' changes value from 18446744073709551584 to -32
      [-Wconstant-conversion]
        emit dataFlow(0-sizeof(buf));
             ~~~~~~~~ ~^~~~~~~~~~~~
2 warnings and 1 error generated.
make[1]: *** [fel.o] Error 1
make: *** [build/hakchi-gui] Error 2

I can confirm the same issue here. Also running macOS 10.12.2 (16C67)

try new commit, should compile now.

I've updated to commit cf9488f, but now I'm getting a different error when trying to compile fel.cpp:

clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 -std=gnu++11 -Wall -Wextra -O2 -arch x86_64 -Wall -W -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++ -I../hakchi-gui -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/include -I../3rdparty/sunxi-tools -I../3rdparty/sunxi-tools/include -I../3rdparty/mkbootimg -I. -I. -I../hakchi-gui -I. -F/usr/local/Cellar/qt/4.8.7_2/lib -o fel.o ../hakchi-gui/src/fel.cpp
../hakchi-gui/src/fel.cpp:16:9: error: use of undeclared identifier 'free'
        free(pointer);
        ^
1 error generated.
make[1]: *** [fel.o] Error 1
make: *** [build/hakchi-gui] Error 2

try to add #include <stdlib.h> on line 8 in fel.cpp

I added the line you mentioned:

diff --git a/hakchi-gui/src/fel.cpp b/hakchi-gui/src/fel.cpp
index 2adc08c..0a8f286 100644
--- a/hakchi-gui/src/fel.cpp
+++ b/hakchi-gui/src/fel.cpp
@@ -5,6 +5,7 @@ extern "C" {
 }
 #include "md5int.h"
 #include <stdio.h>
+#include <stdlib.h>
 
 struct FeldevHandle:public feldev_handle{};
 static const char*fastboot="efex_test";

Another error, related to Qt this time:

clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 -std=gnu++11 -Wall -Wextra -O2 -arch x86_64 -Wall -W -DQT_NO_DEBUG -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.7_2/mkspecs/unsupported/macx-clang-libc++ -I../hakchi-gui -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.7_2/include -I../3rdparty/sunxi-tools -I../3rdparty/sunxi-tools/include -I../3rdparty/mkbootimg -I. -I. -I../hakchi-gui -I. -F/usr/local/Cellar/qt/4.8.7_2/lib -o main.o ../hakchi-gui/src/main.cpp
../hakchi-gui/src/main.cpp:30:26: error: no member named 'fromCFURL' in 'QUrl'
    QString mfn = (QUrl::fromCFURL(url).path());
                   ~~~~~~^
1 error generated.
make[1]: *** [main.o] Error 1
make: *** [build/hakchi-gui] Error 2

But it looks like I needed to update my version of Qt from 4.8 to 5.8, so I did the following:

brew install --force qt5
brew link --overwrite --force qt5
make clean

That fixed the lack of Qt 5.

Now make gives me the following error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9  -o hakchi-gui.app/Contents/MacOS/hakchi-gui fel_lib.o soc_info.o progress.o fel.o main.o mainwindow.o wincon.o worker.o md5int.o moc_fel.o moc_mainwindow.o moc_wincon.o moc_worker.o   -F/usr/local/Cellar/qt5/5.8.0_1/lib -L/usr/local/Cellar/libusb/1.0.20/lib -lusb-1.0 -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL 
Undefined symbols for architecture x86_64:
  "_CFAutorelease", referenced from:
      appPath() in main.o
  "_CFBundleCopyBundleURL", referenced from:
      appPath() in main.o
  "_CFBundleGetMainBundle", referenced from:
      appPath() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [hakchi-gui.app/Contents/MacOS/hakchi-gui] Error 1
make: *** [build/hakchi-gui] Error 2

here I can't help unfortunately. I don't have a mac. see last comments in #16 where this particular error seems to be solved.