conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
949 stars 1.74k forks source link

[package] tensorflow-lite/2.12.0: Compilation fails due to missing <cstdint> include #24538

Closed ducroq closed 1 month ago

ducroq commented 3 months ago

Description

When attempting to build TensorFlow Lite 2.12.0 using Conan, the compilation fails due to 'uint32_t' not being declared in scope. The error suggests that the header is missing in the 'spectrogram.cc' file. This prevents the successful building of the package and integration into projects.

Expected behavior: TensorFlow Lite should compile successfully without any 'uint32_t' related errors. Actual behavior: Compilation fails due to 'uint32_t' not being declared. Workaround attempted: Manually adding '#include ' to the file, but this change is overwritten on subsequent builds.

Package and Environment Details

Conan profile

Host profile: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=13 os=Linux

Build profile: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=13 os=Linux

Steps to reproduce

  1. Create a conanfile.py with the following content:
from conan import ConanFile
from conan.tools.cmake import cmake_layout

class FaceLandmarkerRecipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeDeps", "CMakeToolchain"

    def configure(self):
        self.settings.compiler.cppstd = "17"

    def requirements(self):
        self.requires("tensorflow-lite/2.12.0")
        self.requires("opencv/4.5.5")

    def layout(self):
        cmake_layout(self)
  1. Run the following command:
    conan install . --build=missing

Logs

Click to expand log ``` [ 23%] Building CXX object CMakeFiles/tensorflow-lite.dir/kernels/activations.cc.o /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:46:22: error: 'uint32_t' was not declared in this scope 46 | inline int Log2Floor(uint32_t n) { | ^~~~~~~~ /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:20:1: note: 'uint32_t' is defined in header ''; did you forget to '#include '? 19 | #include +++ |+#include 20 | /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:61:24: error: 'uint32_t' was not declared in this scope 61 | inline int Log2Ceiling(uint32_t n) { | ^~~~~~~~ /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:61:24: note: 'uint32_t' is defined in header ''; did you forget to '#include '? /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:69:8: error: 'uint32_t' does not name a type 69 | inline uint32_t NextPowerOfTwo(uint32_t value) { | ^~~~~~~~ /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:69:8: note: 'uint32_t' is defined in header ''; did you forget to '#include '? /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc: In member function 'bool tflite::internal::Spectrogram::Initialize(const std::vector&, int)': /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/src/tensorflow/lite/kernels/internal/spectrogram.cc:92:17: error: 'NextPowerOfTwo' was not declared in this scope 92 | fft_length_ = NextPowerOfTwo(window_length_); | ^~~~~~~~~~~~~~ gmake[2]: *** [CMakeFiles/tensorflow-lite.dir/build.make:692: CMakeFiles/tensorflow-lite.dir/kernels/internal/spectrogram.cc.o] Error 1 gmake[2]: *** Waiting for unfinished jobs.... gmake[1]: *** [CMakeFiles/Makefile2:119: CMakeFiles/tensorflow-lite.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2 tensorflow-lite/2.12.0: ERROR: Package 'd5492a35ae367384a942dd28b2605867bf2c8120' build failed tensorflow-lite/2.12.0: WARN: Build folder /home/jeroen/.conan2/p/b/tenso2afef9412b5fa/b/build/Release ERROR: tensorflow-lite/2.12.0: Error in build() method, line 139 cmake.build() ConanException: Error 2 while executing ```
Nekto89 commented 3 months ago

this can be added as patch https://github.com/tensorflow/tensorflow/commit/9dbee4329ffd0474b939927f6d337959fb72318a

ducroq commented 3 months ago

this can be added as patch tensorflow/tensorflow@9dbee43

Thank you. I have adapted the code in the cache .conan/p/b/tenso{$hash$}. However, when I execute conan install . --build=missing it simply ignores this and downloads the source again and puts in a different subfolder.

I was hoping to work around the issue by running the patch automatically, and added these methods to conanfile.py:

def build(self):
        apply_conandata_patches(self)
def export_sources(self):
        export_conandata_patches(self)    

And in my patches folder tensorflow-lite.patch:

--- a/tensorflow/lite/kernels/internal/spectrogram.cc
+++ b/tensorflow/lite/kernels/internal/spectrogram.cc
@@ -17,6 +17,7 @@
 #include "tensorflow/lite/kernels/internal/spectrogram.h"

 #include <math.h>
+#include <cstdint>

 #include <algorithm>
 #include <complex>

But no luck, unfortunately.

franramirez688 commented 1 month ago

@ducroq could you try the recent version added to conan-center? Run conan install . --build=missing --update

ducroq commented 1 month ago

sorry, I've dropped conan for now.