Bodmer/TJpg_Decoder

"undefined reference to `BYTECLIP'"

sgrizzi opened this issue ยท 25 comments

Hi, I am compiling the same project described by Jokikill at the beginning of this issue trail.
I am using Platformio, with the latest Espressif 32 platform 4.4.0 and I get the very same error "undefined reference to `BYTECLIP'" at the end of the linking process.
The board is the AI Thinker ESP32-CAM.
Any suggestion on how to solve the problem?
Thanks!

/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32cam/libd91/libTJpg_Decoder.a(tjpgd.c.o):(.literal.jd_decomp+0x18): undefined reference to `BYTECLIP'
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32cam/libd91/libTJpg_Decoder.a(tjpgd.c.o): in function `block_idct':
/Users/gabriele/Documents/PlatformIO/Projects/esp32cam TFT/.pio/libdeps/esp32cam/TJpg_Decoder/src/tjpgd.c:1435: undefined reference to `BYTECLIP'
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /Users/gabriele/Documents/PlatformIO/Projects/esp32cam TFT/.pio/libdeps/esp32cam/TJpg_Decoder/src/tjpgd.c:1436: undefined reference to `BYTECLIP'
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /Users/gabriele/Documents/PlatformIO/Projects/esp32cam TFT/.pio/libdeps/esp32cam/TJpg_Decoder/src/tjpgd.c:1437: undefined reference to `BYTECLIP'
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /Users/gabriele/Documents/PlatformIO/Projects/esp32cam TFT/.pio/libdeps/esp32cam/TJpg_Decoder/src/tjpgd.c:1438: undefined reference to `BYTECLIP'
/Users/gabriele/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32cam/libd91/libTJpg_Decoder.a(tjpgd.c.o):/Users/gabriele/Documents/PlatformIO/Projects/esp32cam TFT/.pio/libdeps/esp32cam/TJpg_Decoder/src/tjpgd.c:1439: more undefined references to `BYTECLIP' follow
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32cam/firmware.elf] Error 1

Originally posted by @sgrizzi in #29 (comment)

Just importing .h file to show an image

.pio/libdeps/fm-devkit/TJpg_Decoder/src/tjpgd.c:1439: more undefined references to `BYTECLIP' follow
collect2: error: ld returned 1 exit status
*** [.pio/build/fm-devkit/firmware.elf] Error 1

V1.0.5 is the latest on Github. Is that the version you are using.

1.0.2? How can I get the latest?

WOW. Platformio installed 0.2.0 by default and does not indicate that any update is available.
Thanks. I will somehow "force" downloading the newer library.

If I try and "force" update to 1.0.5 I get this strange error....

Library Manager: Installing bodmer/TJpg_Decoder @ ^1.0.5
Error: Could not find the package with 'bodmer/TJpg_Decoder @ ^1.0.5' requirements for your system 'darwin_x86_64'
The terminal process "platformio 'run'" terminated with exit code: 1.

I have been running Platformio on my Mac for a few years now, and I am using it regularly to compile and run ESP32 code.
Platformio core is 6.0.2 and the espressif 32 platform is 4.4.0 - should both be up to date...
Do you have any idea on why I chould be getting this error? No problem if I move back to TJpg_Decoder @ ^0.2.0... weird

I have created a release version of 1.0.5 so that should be available when the PlatformIO next updates the links.

Hi Bodmer, still could not upgrade form pio IDE, the default version is 0.2.0 released a year ago, hope you can check that.

Hi Bodmer.
I lost a big amount of time checking what was the problem with my code, and as I encapsulate all in objects, I thougth it was my fault, but now that I clear all warnings and bad practices from it, I see that I have the same error with BYTECLIP after compilation.
I tried to reference directly tjpgd.h and tjpgd.c, but it doesn't work and it's not a good thing anyway.
Searching the problem on the net, I finally found this thread, and of course, I effectively have the same problem. Platform IO only see the 0.2.0 version, and the olders ones (0.1.0 and 0.0.3) but no more. Nor the 1.0.2 or the 1.0.5.
Trying to force it with bodmer/TJpg_Decoder@^1.0.5 in platform IO, I have the same response ;
"Could not find the package with 'bodmer/TJpg_Decoder @ ^1.0.5' requirements for your system 'windows_amd64'"

You seem to make a great work, I have tested TFT-eSPI, and it's faster than Arduino GFX or Adafruit GFX, but I can't use it now as it needs TJPEG_Decoder to work as I want and I must try to put the last version to see if it resolves the problem with BYTECLIP.

I'm a bit disapointed by this problem... why it doesn't fail on compiling since it says a var is not defined.... why after at link time...
I'd like to understand, but what is sure, is that it comes from your package as it desapear since I remove it.

Thanks for your work. I hope I could see it working soon :)

try change
static uint8_t BYTECLIP (int val)
to
uint8_t BYTECLIP (int val)
in tjpgd.c

@pipi61 Thanks for the suggestion. I don't see the error myself so I am unable to check the "undefined problem" goes away. This problem seems to be specific to compilations under PlatformIO which is not an IDE I have used other than to try it a long time ago.

Te code section that generates the error was coded by ChaN and it seems to compile fine under the Arduino IDE.

PlatformIO used to fetch the latest version but at some point during a platformIO services upgrade this stopped working. Posts on the PlatformIO forum indicate there are other libraries that are not being seen as updated as well that have required action by the PlatformIO team.

BYTECLIP is a inline function.
the root cause is compiler, refer to STSTM32 build_flags break โ€˜inlineโ€™ keyword

sorry, miss some infos.
Code of "Platformio installed 0.2.0 by default" is an inline function, So it can't compile successfully.
I installed code of 1.0.5 version manually( ${ProjectPath}/lib/TJpg_Decoder ), It works.

OK, that explains it, thanks everyone.

Ther estill seems to be some issue with the latest version that's in the PlatformIO registry: community thread. Using the latest git version fixed it. Can we get that pushed in the registry, under a new bumped version?

I've tried bumping the version several times, but the registry does not pick this up. Also raised it on the PlatformIO forum but got no repsonse. Looks like others have had the same problem in the past and this needed action from the PlatformIO team.

So it seems the problem is at the PlatformIO end. Not sure who to prompt on this :-(

image

still facing this isuue

But it goes away when you use

lib_deps = 
   https://github.com/Bodmer/TJpg_Decoder.git

in your platformio.ini?

But it goes away when you use

lib_deps = 
   https://github.com/Bodmer/TJpg_Decoder.git

ni your platformio.ini?

yes it work

@Bodmer, sorry for the issue. Currently, PlatformIO uses legacy mode to fetch updates automatically for this library. We plan to remove it soon and highly recommend managing your updates manually using this guide.

Regarding this issue. I've just checked it and I don't see any problems on the PlatformIO side. The library is linked to https://raw.githubusercontent.com/Bodmer/TJpg_Decoder/master/library.json manifest which points to the unknown 1.0.9 version (there is no 1.0.9 or v1.0.9 tag). Typically, we increment the version before making a release/tag.

The solution to this issue is one of:

  1. Revert back https://github.com/Bodmer/TJpg_Decoder/blob/master/library.json#L3 to "version": "1.0.8", the same for library.properties. Versions should be the same in both manifests.
  2. Download ZIP of 1.0.8 from https://github.com/Bodmer/TJpg_Decoder/releases/tag/v1.0.8 and type pio pkg publish path/to/zip. See Publishing instruction.

The 2nd option with the RECOMMENDED solution. Library maintainers should personally decide which SOURCE and VERSION they want to publish to the registry. This is the answer to why we plan soon to stop "automatic fetching" to avoid similar issues.

Happy coding with PlatformIO!

@ivankravets The released version is v1.0.8, the latest master is 1.0.9 but has not been released yet so it is not clear what to do!

I use the Arduino IDE, not PlatformIO so I assume I will not be able to publish libraries to the PlatformIO registry :-(

Looks like latformIO just does not see the latest versions after 0.2.0:

image

I'm not sure that I understand the versioning policy in this repository. If you mean master == release following git-flow branching model, then the version field in this branch should equal to the latest release. In this case, the develop branch should be used instead for trunk/upstream development where you can use pre-release version tags (1.0.9-beta.1, etc). If you have this, we can point the PlatformIO legacy crawler to the library.json located in the master branch which always follows the latest release.

In the current situation, we instructed PlatformIO to use "tagged" branch https://raw.githubusercontent.com/Bodmer/TJpg_Decoder/v1.0.8/library.json
If you release the new version of this library, we will need to update this manifest URL.

So, anyone who uses this library with PlatformIO and sees that it is outdated in the PlatformIO Registry https://registry.platformio.org/libraries/bodmer/TJpg_Decoder, please ping me here. We will manually trigger the "updating" process while the author can't maintain this library himself.

P.S.: The new 1.0.8 is available in the registry. Happy coding with PlatformIO!

Thanks.