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

Compile Error: Undeclared Identifier ‘tsl’ in libtensorflow #66215

Open
HongMJ1315 opened this issue Apr 22, 2024 · 0 comments
Open

Compile Error: Undeclared Identifier ‘tsl’ in libtensorflow #66215

HongMJ1315 opened this issue Apr 22, 2024 · 0 comments
Assignees
Labels
TF 2.16 type:others issues not falling in bug, perfromance, support, build and install or feature wsl2 Windows Subsystem for Linux

Comments

@HongMJ1315
Copy link

HongMJ1315 commented Apr 22, 2024

Issue type

Others

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.16.1

Custom code

Yes

OS platform and distribution

WSL2 on Windows 11

Mobile device

No response

Python version

3.7.12

Bazel version

No response

GCC/compiler version

clang++-16

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

While compiling a test program using libtensorflow, I encountered an issue. The problem seems to be related to an error: use of undeclared identifier 'tsl'.

Standalone code to reproduce the issue

#include <tensorflow/core/platform/env.h>
#include <tensorflow/core/public/session.h>
#include <iostream>

using namespace std;
using namespace tensorflow;

int main(){
    Session *session;
    Status status = NewSession(SessionOptions(), &session);
    if(!status.ok()){
        cout << status.ToString() << "\n";
        return 1;
    }
    cout << "Session successfully created.\n";
}
cmake_minimum_required(VERSION 3.12)

set(MY_PROJECT "tf")
set(MY_EXECUTABLE "hello_tf")

# set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++-11")
project("tf"
    VERSION 0.1.0
    LANGUAGES CXX C
    DESCRIPTION "tf"
)

add_executable(${MY_EXECUTABLE})
set_target_properties(${MY_EXECUTABLE}
    PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
    C_STANDARD 11
    C_STANDARD_REQUIRED ON
)

find_package(absl CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)

# TensorFlow include directory
include_directories("\\home\\mrjb\\tensorflow\\tf_env\\include")
target_include_directories(${MY_EXECUTABLE} PRIVATE "include" ${STB_INCLUDE_DIRS})
file(GLOB MY_SOURCE CONFIGURE_DEPENDS
    "src/*.cc"
    "src/*.c" # Add .c files to be compiled
)
target_sources(${MY_EXECUTABLE} PRIVATE ${MY_SOURCE})

# TensorFlow library directory
link_directories("\\home\\mrjb\\tensorflow\\tf_env\\lib")
link_directories("\\home\\mrjb\\miniconda3\\envs\\main\\lib\\python3.7\\site-packages\\tensorflow_io_gcs_filesystem")

# Link TensorFlow libraries
target_link_libraries(${MY_EXECUTABLE} PRIVATE
    absl::any absl::log absl::base absl::bits
    protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite
    tensorflow
    tensorflow_framework
    tsl
)
target_compile_options(${MY_EXECUTABLE} PRIVATE "-fpermissive")

Relevant log output

/usr/bin/cmake --build /mnt/c/Users/gonec/Documents/C++/tf/build/Debug --config Debug --target all --
[1/2   0% :: 0.000] Re-checking globbed directories...
[1/2  50% :: 2.171] Building CXX object CMakeFiles/hello_tf.dir/src/main.cc.o
FAILED: CMakeFiles/hello_tf.dir/src/main.cc.o 
/usr/bin/clang++-16  -I/home/mrjb/tensorflow/tf_env/include -I/mnt/c/Users/gonec/Documents/C++/tf/include -isystem /home/mrjb/vcpkg/installed/x64-linux/include -g -fpermissive -std=c++17 -MD -MT CMakeFiles/hello_tf.dir/src/main.cc.o -MF CMakeFiles/hello_tf.dir/src/main.cc.o.d -o CMakeFiles/hello_tf.dir/src/main.cc.o -c /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:19:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/bfloat16.h:20:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/byte_order.h:24:32: error: use of undeclared identifier 'tsl'
constexpr bool kLittleEndian = tsl::port::kLittleEndian;
                               ^
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:19:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/bfloat16.h:25:9: error: use of undeclared identifier 'tsl'
typedef tsl::bfloat16 bfloat16;
        ^
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:21:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/tstring.h:21:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/stringpiece.h:33:21: error: use of undeclared identifier 'tsl'
using StringPiece = tsl::StringPiece;
                    ^
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:21:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/tstring.h:26:17: error: use of undeclared identifier 'tsl'
using tstring = tsl::tstring;
                ^
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:27:7: error: use of undeclared identifier 'tsl'
using tsl::string;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:29:7: error: use of undeclared identifier 'tsl'
using tsl::uint16;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:30:7: error: use of undeclared identifier 'tsl'
using tsl::uint32;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:31:7: error: use of undeclared identifier 'tsl'
using tsl::uint4;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:32:7: error: use of undeclared identifier 'tsl'
using tsl::uint64;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:33:7: error: use of undeclared identifier 'tsl'
using tsl::uint8;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:35:7: error: use of undeclared identifier 'tsl'
using tsl::int16;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:36:7: error: use of undeclared identifier 'tsl'
using tsl::int32;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:37:7: error: use of undeclared identifier 'tsl'
using tsl::int4;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:38:7: error: use of undeclared identifier 'tsl'
using tsl::int64;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:39:7: error: use of undeclared identifier 'tsl'
using tsl::int8;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:41:7: error: use of undeclared identifier 'tsl'
using tsl::float8_e4m3fn;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:42:7: error: use of undeclared identifier 'tsl'
using tsl::float8_e5m2;
      ^
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:44:14: error: unknown type name 'uint8'; did you mean 'uint'?
static const uint8 kuint8max = tsl::kuint8max;
             ^~~~~
             uint
/usr/include/x86_64-linux-gnu/sys/types.h:150:22: note: 'uint' declared here
typedef unsigned int uint;
                     ^
In file included from /mnt/c/Users/gonec/Documents/C++/tf/src/main.cc:1:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env.h:26:
In file included from /home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/env_time.h:20:
/home/mrjb/tensorflow/tf_env/include/tensorflow/core/platform/types.h:44:32: error: use of undeclared identifier 'tsl'
static const uint8 kuint8max = tsl::kuint8max;
                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.
@google-ml-butler google-ml-butler bot added the type:others issues not falling in bug, perfromance, support, build and install or feature label Apr 22, 2024
@SuryanarayanaY SuryanarayanaY added wsl2 Windows Subsystem for Linux TF 2.16 labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TF 2.16 type:others issues not falling in bug, perfromance, support, build and install or feature wsl2 Windows Subsystem for Linux
Projects
None yet
Development

No branches or pull requests

3 participants