Page 1 of 1

undefined reference to `CAN_LookUpChanel'

Posted: Mon 18. Mar 2024, 12:11
by aniol2001
Hi,

I am using Windows 10 and the TDM-GCC compiler to compile the code. Recently, I attempted to use the PCANBasic API in C++ and encountered several errors. The drivers are correctly installed and updated, and I'm trying to compile using `g++ main.cpp -o main.o`, but I'm receiving the following error:

```
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\aniol\AppData\Local\Temp\1\cc7Q9LYj.o:main.cpp:(.text+0x63): undefined reference to `CAN_LookUpChannel'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\aniol\AppData\Local\Temp\1\cc7Q9LYj.o:main.cpp:(.text+0x8b): undefined reference to `CAN_GetErrorText'
collect2.exe: error: ld returned 1 exit status.
```

I will attach the code to provide more information about the error. Interestingly, when I attempt to call the functions from the PCANBasic header, the Visual Studio Code interface recognizes them and shows me the proper information about the functions (this will be attached as well).

Re: undefined reference to `CAN_LookUpChanel'

Posted: Mon 18. Mar 2024, 14:19
by PEAK-Support
We already answer you in detail that this is a programming skill problem and have nothing to do with our APIs / DLLs.
You need to understand how a DLL and the needed LIB for different compilers / linker work.
We close this post now and maybe will delete it later on...douple posting / sending e-mail with the same question do not make any sense...

For all the rest who are interested what this users "problem" is - google for gcc dlltool and gendef

"with gendef and dlltool, both part of any MinGW-w64 distribution, you can now quite easily generate GCC import libraries from any DLL"
Interestingly, when I attempt to call the functions from the PCANBasic header, the Visual Studio Code interface recognizes them and shows me the proper information about the functions (this will be attached as well).
The Visual Studio Code is a EDITOR ! nor more not less ! could be extend by several tools also Syntax Highlighter like IntelliSense
This Tools simply parse the included header and show the the inside the header stored text information when type this function into the Editor...This have absolutely nothing to do that the compiler know anything about this functionality ...it is a VSCode Tool...

* we also moved the Topic to the correct Section *