I cannot compile the pcanbasic

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
sara_123
Posts: 4
Joined: Mon 1. Nov 2021, 23:17

I cannot compile the pcanbasic

Post by sara_123 » Mon 1. Nov 2021, 23:28

Hello
I am using Linux system and try to run the sample code and compile it but I tried both from command line or adding it to an eclipse c and c++ project. in both cases I receive error messages that some of header file does not exist.

operating system: Fedora 33
Building file: ../pcaninfo/src/main.c
Invoking: GCC C Compiler

Code: Select all

gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"pcaninfo/src/main.d" -MT"pcaninfo/src/main.o" -o "pcaninfo/src/main.o" "../pcaninfo/src/main.c"
../pcaninfo/src/main.c:74:27: error: unknown type name ‘TPCANHandle’
   74 | char * pretty_tpcanhandle(TPCANHandle channel, char * buf, int size) {
      |                           ^~~~~~~~~~~
../pcaninfo/src/main.c: In function ‘print_version_pcanbasic’:
../pcaninfo/src/main.c:182:18: error: expected declaration specifiers or ‘...’ before ‘*’ token
  182 |   typedef __u32 (*fCAN_GetValue)(__u16 channel, __u8 param, void* buf, __u32 bufsize);
      |                  ^
../pcaninfo/src/main.c:187:3: error: unknown type name ‘fCAN_GetValue’
  187 |   fCAN_GetValue pCAN_GetValue = (fCAN_GetValue) dlsym(handle, PCANBASIC_GETVALUE);
      |   ^~~~~~~~~~~~~
../pcaninfo/src/main.c:187:34: error: ‘fCAN_GetValue’ undeclared (first use in this function); did you mean ‘pCAN_GetValue’?
  187 |   fCAN_GetValue pCAN_GetValue = (fCAN_GetValue) dlsym(handle, PCANBASIC_GETVALUE);
      |                                  ^~~~~~~~~~~~~
      |                                  pCAN_GetValue
../pcaninfo/src/main.c:187:34: note: each undeclared identifier is reported only once for each function it appears in
../pcaninfo/src/main.c:187:49: error: expected ‘,’ or ‘;’ before ‘dlsym’
  187 |   fCAN_GetValue pCAN_GetValue = (fCAN_GetValue) dlsym(handle, PCANBASIC_GETVALUE);
      |                                                 ^~~~~
../pcaninfo/src/main.c:191:4: error: unknown type name ‘__u32’
  191 |    __u32 sts;
      |    ^~~~~
../pcaninfo/src/main.c:193:27: error: ‘PCAN_API_VERSION’ undeclared (first use in this function)
  193 |    sts = pCAN_GetValue(0, PCAN_API_VERSION, buf, sizeof(buf));
      |                           ^~~~~~~~~~~~~~~~
../pcaninfo/src/main.c:193:10: error: called object ‘pCAN_GetValue’ is not a function or function pointer
  193 |    sts = pCAN_GetValue(0, PCAN_API_VERSION, buf, sizeof(buf));
      |          ^~~~~~~~~~~~~
../pcaninfo/src/main.c:187:17: note: declared here
  187 |   fCAN_GetValue pCAN_GetValue = (fCAN_GetValue) dlsym(handle, PCANBASIC_GETVALUE);
      |                 ^~~~~~~~~~~~~
../pcaninfo/src/main.c: In function ‘main’:
../pcaninfo/src/main.c:212:2: error: unknown type name ‘PCANLOG_LEVEL’
  212 |  PCANLOG_LEVEL log_lvl;
      |  ^~~~~~~~~~~~~
../pcaninfo/src/main.c:218:2: error: unknown type name ‘TPCANHandle’
  218 |  TPCANHandle hdl;
      |  ^~~~~~~~~~~
../pcaninfo/src/main.c:228:12: error: ‘LVL_NORMAL’ undeclared (first use in this function)
  228 |  log_lvl = LVL_NORMAL;
      |            ^~~~~~~~~~
../pcaninfo/src/main.c:270:13: error: ‘LVL_VERBOSE’ undeclared (first use in this function)
  270 |   log_lvl = LVL_VERBOSE;
      |             ^~~~~~~~~~~
../pcaninfo/src/main.c:272:13: error: ‘LVL_DEBUG’ undeclared (first use in this function)
  272 |   log_lvl = LVL_DEBUG;
      |             ^~~~~~~~~
../pcaninfo/src/main.c:273:2: warning: implicit declaration of function ‘pcanlog_set’ [-Wimplicit-function-declaration]
  273 |  pcanlog_set(log_lvl, 0, log_lvl == LVL_DEBUG);
      |  ^~~~~~~~~~~
../pcaninfo/src/main.c:277:9: warning: implicit declaration of function ‘pcaninfo_get’ [-Wimplicit-function-declaration]
  277 |  ires = pcaninfo_get(&pcilist, 1);
      |         ^~~~~~~~~~~~
../pcaninfo/src/main.c:281:13: error: invalid use of undefined type ‘struct pcaninfo_list’
  281 |  if (pcilist->version[0] != 0)
      |             ^~
../pcaninfo/src/main.c:282:55: error: invalid use of undefined type ‘struct pcaninfo_list’
  282 |   fprintf(stdout, "PCAN driver version: %s\n", pcilist->version);
      |                                                       ^~
../pcaninfo/src/main.c:290:25: error: invalid use of undefined type ‘struct pcaninfo_list’
  290 |  for (i = 0; i < pcilist->length; i++) {
      |                         ^~
../pcaninfo/src/main.c:299:23: error: invalid use of undefined type ‘struct pcaninfo_list’
  299 |     if (strstr(pcilist->infos[i].name, device) != 0) {
      |                       ^~
../pcaninfo/src/main.c:303:28: error: invalid use of undefined type ‘struct pcaninfo_list’
  303 |     else if (strstr(pcilist->infos[i].path, device) != 0) {
      |                            ^~
../pcaninfo/src/main.c:308:12: warning: implicit declaration of function ‘pcanbasic_get_handle’ [-Wimplicit-function-declaration]
  308 |      hdl = pcanbasic_get_handle(pcilist->infos[i].path, pcilist);
      |            ^~~~~~~~~~~~~~~~~~~~
../pcaninfo/src/main.c:308:40: error: invalid use of undefined type ‘struct pcaninfo_list’
  308 |      hdl = pcanbasic_get_handle(pcilist->infos[i].path, pcilist);
      |                                        ^~
../pcaninfo/src/main.c:309:17: warning: implicit declaration of function ‘pretty_tpcanhandle’ [-Wimplicit-function-declaration]
  309 |      if (strstr(pretty_tpcanhandle(hdl, buf, BUF_SIZE), device) != 0) {
      |                 ^~~~~~~~~~~~~~~~~~
../pcaninfo/src/main.c:309:17: warning: passing argument 1 of ‘strstr’ makes pointer from integer without a cast [-Wint-conversion]
  309 |      if (strstr(pretty_tpcanhandle(hdl, buf, BUF_SIZE), device) != 0) {
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 int
In file included from ../pcaninfo/src/main.c:36:
/usr/include/string.h:334:34: note: expected ‘const char *’ but argument is of type ‘int’
  334 | extern char *strstr (const char *__haystack, const char *__needle)
      |                      ~~~~~~~~~~~~^~~~~~~~~~
../pcaninfo/src/main.c:317:38: error: invalid use of undefined type ‘struct pcaninfo_list’
  317 |    hdl = pcanbasic_get_handle(pcilist->infos[i].path, pcilist);
      |                                      ^~
../pcaninfo/src/main.c:320:44: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=]
  320 |     snprintf(str_hdl, sizeof(str_hdl), "\"%s\" (0x%03x)", pretty_tpcanhandle(hdl, buf, BUF_SIZE), hdl);
      |                                           ~^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                            |              |
      |                                            char *         int
      |                                           %d
../pcaninfo/src/main.c:321:5: warning: implicit declaration of function ‘pcaninfo_output_summary’ [-Wimplicit-function-declaration]
  321 |     pcaninfo_output_summary(&pcilist->infos[i], str_hdl);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
../pcaninfo/src/main.c:321:37: error: invalid use of undefined type ‘struct pcaninfo_list’
  321 |     pcaninfo_output_summary(&pcilist->infos[i], str_hdl);
      |                                     ^~
../pcaninfo/src/main.c:324:5: warning: implicit declaration of function ‘pcaninfo_output’ [-Wimplicit-function-declaration]
  324 |     pcaninfo_output(&pcilist->infos[i]);
      |     ^~~~~~~~~~~~~~~
../pcaninfo/src/main.c:324:29: error: invalid use of undefined type ‘struct pcaninfo_list’
  324 |     pcaninfo_output(&pcilist->infos[i]);
      |                             ^~
../pcaninfo/src/main.c:325:44: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
  325 |     fprintf(stdout, "  \t- TPCANHandle: \"%s\" (0x%03x)\n", pretty_tpcanhandle(hdl, buf, BUF_SIZE), hdl);
      |                                           ~^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                            |                |
      |                                            char *           int
      |                                           %d
../pcaninfo/src/main.c:332:14: error: invalid use of undefined type ‘struct pcaninfo_list’
  332 |   if (pcilist->version[0] == 0) {
      |              ^~
../pcaninfo/src/main.c:335:15: error: invalid use of undefined type ‘struct pcaninfo_list’
  335 |    if (pcilist->length > 0) {
      |               ^~
make: *** [pcaninfo/src/subdir.mk:20: pcaninfo/src/main.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

23:13:14 Build Failed. 25 errors, 9 warnings. (took 318ms)
can anybody urgently help me
Last edited by K.Wagner on Tue 2. Nov 2021, 08:07, edited 1 time in total.
Reason: Code formatting for better reading

M.Maidhof
Support
Support
Posts: 1366
Joined: Wed 22. Sep 2010, 14:00

Re: I cannot compile the pcanbasic

Post by M.Maidhof » Tue 2. Nov 2021, 10:47

Hi,

please install the PCANBasic through our peak-linux-driver-8.13 Linux driver, to have all necessary files available. Looks like you posted the driver installation already in an other post, isn't it?

regards

Michael

Post Reply