Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Compilation Errors on Linux Debian #14

Open
MKesenheimer opened this issue Feb 3, 2023 · 5 comments
Open

Various Compilation Errors on Linux Debian #14

MKesenheimer opened this issue Feb 3, 2023 · 5 comments

Comments

@MKesenheimer
Copy link

MKesenheimer commented Feb 3, 2023

Hey,
I got various compilation errors on a recent Debian distribution.

GCC Version:

gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compilation errors:

In file included from ./src/jtag/jtag.h:15,
                 from src/openocd.c:20:
./src/flash/nor/core.h: In function ‘report_flash_progress’:
./src/flash/nor/core.h:283:11: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=format=]
  283 |  LOG_INFO("%s:0x%llx|0x%llx|%s", op, region_start, region_end, block_name);
      |           ^~~~~~~~~~~~~~~~~~~~~      ~~~~~~~~~~~~
      |                                      |
      |                                      uint64_t {aka long unsigned int}
./src/helper/log.h:118:60: note: in definition of macro ‘LOG_INFO’
  118 |  log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr)
      |                                                            ^~~~
In file included from src/openocd.c:24:
./src/flash/nor/core.h:283:20: note: format string is defined here
  283 |  LOG_INFO("%s:0x%llx|0x%llx|%s", op, region_start, region_end, block_name);
      |                 ~~~^
      |                    |
      |                    long long unsigned int
      |                 %lx
In file included from ./src/jtag/jtag.h:15,
                 from src/openocd.c:20:
./src/flash/nor/core.h:283:11: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 8 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=format=]
  283 |  LOG_INFO("%s:0x%llx|0x%llx|%s", op, region_start, region_end, block_name);
      |           ^~~~~~~~~~~~~~~~~~~~~                    ~~~~~~~~~~
      |                                                    |
      |                                                    uint64_t {aka long unsigned int}
./src/helper/log.h:118:60: note: in definition of macro ‘LOG_INFO’
  118 |  log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr)
      |                                                            ^~~~
In file included from src/openocd.c:24:
./src/flash/nor/core.h:283:27: note: format string is defined here
  283 |  LOG_INFO("%s:0x%llx|0x%llx|%s", op, region_start, region_end, block_name);
      |                        ~~~^
      |                           |
      |                           long long unsigned int
      |                        %lx
In file included from ./src/jtag/jtag.h:15,
                 from src/openocd.c:20:
src/openocd.c: In function ‘setup_command_handler’:
src/openocd.c:272:24: error: expected ‘)’ before ‘LIBUSB1_COMMIT’
  272 |  LOG_OUTPUT("libusb1 " LIBUSB1_COMMIT "\n");
      |                        ^~~~~~~~~~~~~~
./src/helper/log.h:133:59: note: in definition of macro ‘LOG_OUTPUT’
  133 |  log_printf(LOG_LVL_OUTPUT, __FILE__, __LINE__, __func__, expr)
      |                                                           ^~~~
In file included from src/openocd.c:24:
At top level:
./src/flash/nor/core.h:281:13: error: ‘report_flash_progress’ defined but not used [-Werror=unused-function]
  281 | static void report_flash_progress(const char *op, uint64_t region_start, uint64_t region_end, const char *block_name)
      |             ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Any ideas?

@MKesenheimer
Copy link
Author

These errors do not occur when compiling the original branch (https://github.com/openocd-org/openocd).

@MKesenheimer
Copy link
Author

MKesenheimer commented Feb 3, 2023

Oh, and the error codes ERROR_SUCCESS, E_FAIL, ERROR_TIMEOUT, ERROR_BAD_ARGUMENTS and ERROR_INSUFFICIENT_BUFFER are undefined, too.

@MKesenheimer
Copy link
Author

Moreover:
The linker can not find stricmp on linux.
stricmp is Windows-specific. Use strcasecmp for linux instead.

@MKesenheimer
Copy link
Author

I think the main issue comes from the fact, that you never built on Linux or other platforms than Windows. Maybe you can try building the software on a different platform and fix the issues?
Thanks!

@MKesenheimer
Copy link
Author

I created a pull request where I pushed the changes that I made to your code. With these changes the project builds on Linux and macOS. This should help to see where changes are necessary, however, these changes are more or less "hacks". Most of the changes should not make it into a release.

For instance, I removed the following flash definitions, since the linker had problems finding them:

Undefined symbols for architecture x86_64:
  "_aducm302x_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_aducm4x50_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_msp432p4_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_pic32mm_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_plugin_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_rs14100_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_stm32g0x_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_stm32g4x_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)
  "_stm32l5x_flash", referenced from:
      _flash_drivers in libopenocd.a(drivers.o)

Maybe you have a better idea how to define these symbols in order that the linker finds them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant