Problems compiling (mktplinkfw.c) on Fedora

Trying to compile mktplinkfw, installed the dependencies, went through the same steps as the post from last year with a very similar problem. His solution didn't work for me. I'm getting this when running gcc -Os mktplinkfw.c mktplinkfw-lib.c md5.c -o mktplinkfw

mktplinkfw.c: In function ‘fill_header’:
mktplinkfw.c:412:34: warning: implicit declaration of function ‘bswap_32’ [-Wimplicit-function-declaration]
  412 |                 hdr->kernel_la = bswap_32(hdr->kernel_la);
      |                                  ^~~~~~~~
In file included from mktplinkfw.c:27:
mktplinkfw.c: At top level:
mktplinkfw-lib.h:61:13: warning: inline function ‘inspect_fw_pmd5sum’ declared but never defined
   61 | inline void inspect_fw_pmd5sum(const char *label, const uint8_t *val, const char *text);
      |             ^~~~~~~~~~~~~~~~~~
mktplinkfw-lib.h:60:13: warning: inline function ‘inspect_fw_phexdec’ declared but never defined
   60 | inline void inspect_fw_phexdec(const char *label, uint32_t val);
      |             ^~~~~~~~~~~~~~~~~~
mktplinkfw-lib.h:59:13: warning: inline function ‘inspect_fw_phex’ declared but never defined
   59 | inline void inspect_fw_phex(const char *label, uint32_t val);
      |             ^~~~~~~~~~~~~~~
mktplinkfw-lib.h:58:13: warning: inline function ‘inspect_fw_pstr’ declared but never defined
   58 | inline void inspect_fw_pstr(const char *label, const char *str);
      |             ^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccK4fYsa.o: in function `fill_header':
mktplinkfw.c:(.text+0x1cf): undefined reference to `bswap_32'
/usr/bin/ld: mktplinkfw.c:(.text+0x1dc): undefined reference to `bswap_32'
/usr/bin/ld: /tmp/ccK4fYsa.o: in function `main':
mktplinkfw.c:(.text.startup+0x678): undefined reference to `inspect_fw_pstr'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x688): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x6ce): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x732): undefined reference to `inspect_fw_pmd5sum'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x753): undefined reference to `inspect_fw_pmd5sum'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x764): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x777): undefined reference to `inspect_fw_pmd5sum'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x788): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7a0): undefined reference to `inspect_fw_pstr'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7ae): undefined reference to `inspect_fw_pstr'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7bd): undefined reference to `inspect_fw_phex'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7cc): undefined reference to `inspect_fw_phex'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7db): undefined reference to `inspect_fw_phex'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x7f7): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x809): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x818): undefined reference to `inspect_fw_phex'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x827): undefined reference to `inspect_fw_phex'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x839): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x84b): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x85d): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x86f): undefined reference to `inspect_fw_phexdec'
/usr/bin/ld: mktplinkfw.c:(.text.startup+0x87e): undefined reference to `inspect_fw_phexdec'
collect2: error: ld returned 1 exit status

Any idea what I am missing?
Thank you.

Fred

Needs _GNU_SOURCE defined probably.

edit:

--- a/tools/firmware-utils/src/mktplinkfw-lib.h
+++ b/tools/firmware-utils/src/mktplinkfw-lib.h
@@ -55,10 +55,10 @@ void get_md5(const char *data, int size, uint8_t *md5);
 int get_file_stat(struct file_info *fdata);
 int read_to_buf(const struct file_info *fdata, char *buf);
 int write_fw(const char *ofname, const char *data, int len);
-inline void inspect_fw_pstr(const char *label, const char *str);
-inline void inspect_fw_phex(const char *label, uint32_t val);
-inline void inspect_fw_phexdec(const char *label, uint32_t val);
-inline void inspect_fw_pmd5sum(const char *label, const uint8_t *val, const char *text);
+void inspect_fw_pstr(const char *label, const char *str);
+void inspect_fw_phex(const char *label, uint32_t val);
+void inspect_fw_phexdec(const char *label, uint32_t val);
+void inspect_fw_pmd5sum(const char *label, const uint8_t *val, const char *text);
 int build_fw(size_t header_size);

 #endif /* mktplinkfw_lib_h */
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -7,6 +7,7 @@
  *   Copyright (C) 2008,2009 Wang Jian <lark@linux.net.cn>
  */

+#include <byteswap.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>

edit2: so the actual Makefile calls -fgnu89-inline . That also works. No idea why they decided to do this.

2 Likes

Yes! That seemed to work... I mean... after compiling, got nothing else on the screen :wink:

Thank you very much.
Fred

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.