Cannot Compile
K0K0 opened this issue · comments
bash: ./kindletool: cannot execute binary file
cannot compile:
make
make -C KindleTool all
make[1]: Entering directory /home/kkostya/Desktop/NiLuJe-KindleTool-7bd6f7a/KindleTool' KT_VERSION = v1.2-GIT make[1]: Leaving directory
/home/kkostya/Desktop/NiLuJe-KindleTool-7bd6f7a/KindleTool'
make[1]: Entering directory /home/kkostya/Desktop/NiLuJe-KindleTool-7bd6f7a/KindleTool' mkdir -p Release cc -Iincludes -O2 -fomit-frame-pointer -march=native -pipe -Wall -Wformat -Wformat-security -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DKT_VERSION='"v1.2-GIT"' -DKT_USERATHOST='"kkostya@kkostya-MS-7309"' -o Release/kindle_tool.o -c kindle_tool.c cc -Iincludes -O2 -fomit-frame-pointer -march=native -pipe -Wall -Wformat -Wformat-security -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DKT_VERSION='"v1.2-GIT"' -DKT_USERATHOST='"kkostya@kkostya-MS-7309"' -o Release/create.o -c create.c cc -Iincludes -O2 -fomit-frame-pointer -march=native -pipe -Wall -Wformat -Wformat-security -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DKT_VERSION='"v1.2-GIT"' -DKT_USERATHOST='"kkostya@kkostya-MS-7309"' -o Release/convert.o -c convert.c cc -Iincludes -O2 -fomit-frame-pointer -march=native -pipe -Wall -Wformat -Wformat-security -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DKT_VERSION='"v1.2-GIT"' -DKT_USERATHOST='"kkostya@kkostya-MS-7309"' -Llib -Wl,-O1 -Wl,--as-needed -oRelease/kindletool Release/kindle_tool.o Release/create.o Release/convert.o -larchive -lz -lcrypto -ldl Release/create.o: In function
metadata_filter':
create.c:(.text+0x11): undefined reference to archive_read_disk_can_descend' create.c:(.text+0x1e): undefined reference to
archive_match_new'
create.c:(.text+0x30): undefined reference to archive_match_exclude_pattern' create.c:(.text+0x48): undefined reference to
archive_match_exclude_pattern'
create.c:(.text+0x5c): undefined reference to archive_match_path_excluded' create.c:(.text+0x71): undefined reference to
archive_match_free'
create.c:(.text+0xad): undefined reference to archive_match_free' Release/create.o: In function
kindle_create_package_archive':
create.c:(.text+0x577): undefined reference to archive_read_disk_set_metadata_filter_callback' Release/create.o: In function
kindle_create_main':
create.c:(.text+0x272d): undefined reference to archive_match_new' create.c:(.text+0x2748): undefined reference to
archive_match_exclude_pattern'
create.c:(.text+0x2774): undefined reference to archive_match_path_excluded' create.c:(.text+0x2791): undefined reference to
archive_match_free'
create.c:(.text+0x2fd7): undefined reference to archive_match_free' collect2: ld returned 1 exit status make[1]: *** [kindletool] Error 1 make[1]: Leaving directory
/home/kkostya/Desktop/NiLuJe-KindleTool-7bd6f7a/KindleTool'
make: *** [all] Error 2
I am using Ubuntu and I tried to install archive library from apt-get and manually building it but it still says it cannot find those functions.
Which version of libarchive did you install via apt? And on which version of Ubuntu?
If it went this far, it should be something newer than libarchive 3.0.3, but let's be sure ;).
On a wild guess, try doing make LDFLAGS=""
to check if that's not simply Ubuntu's toolchain being stupid with ld's as-needed setting...
I just checked ubuntu's package db... I loooove their package names...
You'll need: libarchive-dev
and libarchive12
, NOT libarchive1
...
Because, of course, it's more fun if the there's one dev package for two different version of the library, with a different API... And since I only check the headers (libarchive-dev), if they don't match with the actual library, it'll happily compile and then horribly fail to link when it tries to pull stuff that was implemented in libarchive 3 from a libarchive 2 shared library...
Thank you for a quick reply. I had all three packages installed but still after uninstalling libarchive1 I had the same errors. I tried compiling libarchive 3.0.3 and 3.0.4 from libarchive's website but it didn't work. Can you give me a direct link to where you found the library source code so I will try to compile it again?
And I am running 12.04.
Just to try to understand Ubuntu's packaging: Which version of libarchive-dev
and libarchive12
do you have installed?
If you want to do it the hard way:
- Get libarchive-3.0.4 from http://libarchive.github.com/
- Configure it (I do a minimal build for the binary packages:
./configure --enable-static --disable-shared --disable-xattr --disable-acl --with-zlib --without-bz2lib --without-lzmadec --without-iconv --without-lzma --without-nettle --without-expat --without-xml2
) - Build it
- DON'T install it
- Instead, create an
includes
directory inNiLuJe-KindleTool-7bd6f7a/KindleTool/
(OrKindleTool/KindleTool/
on a git clone) - Copy
archive.h
&archive_entry.h
from thelibarchive-3.0.4/libarchive
directory in that includes directory - Create a
lib
directory inNiLuJe-KindleTool-7bd6f7a/KindleTool/
(OrKindleTool/KindleTool/
on a git clone) - Copy
libarchive.a
from thelibarchive-3.0.4/.libs
directory in that lib directory - And finally,
make clean && make
in KindleTool
That doesn't tell me which version you had installed ;).
As to why not install it in the default /usr/local prefix:
- Because I don't like to clutter a system with out-of-PMS stuff, even in /usr/local or /opt
- More importantly, I have absolutely no idea if said prefix is checked at all, or before the system paths, which would defeat the whole purpose of this, because GCC/LD would then still happily use the stuff installed from apt (without a Makefile tweak, I mean).
- The default Makefiles will look into
includes
andlib
inKindleTool/KindleTool
for this exact purpose, you're not the first ubuntu user that made me curse at the debian/ubuntu libarchive packages ;).
I love apt-get. Usually there is no problems except this one time. Thanks for spending so much time helping me!
Also for some reason the pre-build executable does not work. I think it said it's for 64 bit processors. I have a 64-bit processor, but I installed 32-bit Ubuntu, and there is no easy way to update to x64 version :(
The linux-i686 (not linux-x86_64) static builds should work fine on virtually every 32-bit system (provided you're at least running Linux 2.6.39), if it doesn't, I messed up, and I'd like to know what the exact problem is ;).
The x86_64 64-bit binary, on the other hand, is targeted at Intel Core2 CPUs, so it may fail on some old AMD Athlon CPUs.
On a sidenote, I'll push a new commit in a few minutes to try to deal with the Ubuntu/Debian case a bit more smartly to detect libarchive, please check it out and tell me if it helps ^^.
(With a clean/empty KindleTool/lib & KindleTool/includes folder, of course ^^)
I tried recompiling again, with the new version, and it worked without recompiling the library! Thanks!
Great! Thanks for checking ;).
After looking at the history of Debian's libarchive package, I get why it's working the way it is, and that makes it behave in a way I wasn't expecting. Since I'm not using a buildsystem, the Makefile has to make some assumptions, but it wasn't enough to cover this case :).