serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel

Home Page:https://serizba.github.io/cppflow/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CppFlow/ops.h missing

Dazzid opened this issue · comments

Following the installation instructions, when running 'make' I have this error:

/Users/david/Desktop/cppflow/examples/load_model/main.cpp:3:10: fatal error: 'cppflow/ops.h' file not found #include "cppflow/ops.h"

I might be messing a step?

Hi @Dazzid

How did you install the library? I have to update the docs, because since one of the latest PR, now the library is installed with CMake. You can check that PR here, and follow the instructions.

Hope this helps!

Hi @serizba
Ok, I'm testing with the M1 Pro chip and tried opening the Terminal in Rosseta mode but now I have this error:
ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

The instructions I'm following are this:
git clone https://github.com/serizba/cppflow
cd cppflow
mkdir build
cd build
cmake -DBUILD_EXAMPLES=ON ..
make -j8

So, the error is produced when you do the make -j8? What else is said in the error message?

yes, after make -j8

ld: symbol(s) not found for architecture arm64
clang: clangclang: : clang: clang: error: error: linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)error:
error:
linker command failed with exit code 1 (use -v to see invocation)
linker command failed with exit code 1 (use -v to see invocation)
error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [examples/multi_input_output/multi_input_output] Error 1
make[2]: *** [examples/load_model/load_model] Error 1
make[2]: *** [examples/efficientnet/efficientnet] Error 1
make[2]: *** [examples/tensor/tensor] Error 1
make[2]: *** [examples/eager_op_multithread/eager_op_multithread] Error 1
make[1]: *** [examples/load_model/CMakeFiles/load_model.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [examples/multi_input_output/CMakeFiles/multi_input_output.dir/all] Error 2
make[1]: *** [examples/tensor/CMakeFiles/tensor.dir/all] Error 2
make[1]: *** [examples/efficientnet/CMakeFiles/efficientnet.dir/all] Error 2
make[1]: *** [examples/eager_op_multithread/CMakeFiles/eager_op_multithread.dir/all] Error 2
make: *** [all] Error 2

But, doesn't it says what is the symbol that it's not found?

Ah, I copied the last part

[ 9%] Linking CXX executable efficientnet
[ 18%] Linking CXX executable load_model
[ 27%] Linking CXX executable eager_op_multithread
[ 36%] Linking CXX executable tensor
[ 45%] Linking CXX executable multi_input_output
ld: warning: ld: warning: ld: warning: ld: warning: ignoring file /usr/local/lib/libtensorflow.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64ignoring file /usr/local/lib/libtensorflow.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/lib/libtensorflow.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64ignoring file /usr/local/lib/libtensorflow.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

ignoring file /usr/local/lib/libtensorflow.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_TFE_DeleteContext", referenced from:
Undefined symbols for architecture arm64:
"_TFE_DeleteContext", referenced from:
Undefined symbols for architecture arm64:
"_TFE_DeleteContext", referenced from:
Undefined symbols for architecture arm64:
"_TFE_DeleteContext", referenced from:
Undefined symbols for architecture arm64:
"_TFE_DeleteContext", referenced from:
cppflow::context::~context() in main.cpp.o
cppflow::context::~context() in main.cpp.o
cppflow::context::~context() in main.cpp.o
cppflow::context::~context() in main.cpp.o
cppflow::context::~context() in main.cpp.o
"_TFE_DeleteContextOptions", referenced from:
"_TFE_DeleteContextOptions", referenced from:
"_TFE_DeleteContextOptions", referenced from:
"_TFE_DeleteContextOptions", referenced from:
"_TFE_DeleteContextOptions", referenced from:
cppflow::context::context(TFE_ContextOptions*) in main.cpp.o
cppflow::context::context(TFE_ContextOptions*) in main.cpp.o
cppflow::context::context(TFE_ContextOptions*) in main.cpp.o
cppflow::context::context(TFE_ContextOptions*) in main.cpp.o
"_TFE_DeleteOp", referenced from:
"_TFE_DeleteOp", referenced from:
cppflow::context::context(TFE_ContextOptions*) in main.cpp.o
cppflow::mul(cppflow::tensor const&, cppflow::tensor const&) in main.cpp.o
cppflow::fill(cppflow::tensor const&, cppflow::tensor const&, TF_DataType) in main.cpp.o
cppflow::add(cppflow::tensor const&, cppflow::tensor const&) in main.cpp.o
cppflow::tensor::shape() const in main.cpp.o
cppflow::add(cppflow::tensor const&, cppflow::tensor const&) in main.cpp.o
"_TFE_DeleteOp", referenced from:
cppflow::string_format(std::__1::vector<cppflow::tensor, std::__1::allocatorcppflow::tensor > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, long long) in main.cpp.o
"_TFE_DeleteOp", referenced from:
"_TFE_DeleteTensorHandle", referenced from:
cppflow::tensor::tensor(TFE_TensorHandle*) in main.cpp.o
"_TFE_DeleteOp", referenced from:
cppflow::tensor::tensor(TF_DataType, void const*, unsigned long, std::__1::vector<long long, std::__1::allocator > const&) in main.cpp.o
"_TFE_DeleteTensorHandle", referenced from:

(...)

ld: symbol(s) not found for architecture arm64
"_TF_SessionRun", referenced from:
cppflow::model::operator()(std::__1::vector<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, cppflow::tensor>, std::__1::allocator<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, cppflow::tensor> > >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > >) in main.cpp.o
"_TF_TensorByteSize", referenced from:
std::__1::vector<float, std::__1::allocator > cppflow::tensor::get_data() const in main.cpp.o
cppflow::tensor::tensor(TF_DataType, void const*, unsigned long, std::__1::vector<long long, std::__1::allocator > const&) in main.cpp.o
ld: symbol(s) not found for architecture arm64
"_TF_TensorData", referenced from:
std::__1::vector<float, std::__1::allocator > cppflow::tensor::get_data() const in main.cpp.o
cppflow::to_string(cppflow::tensor const&) in main.cpp.o
cppflow::tensor::tensor(TF_DataType, void const*, unsigned long, std::__1::vector<long long, std::__1::allocator > const&) in main.cpp.o
"_TF_TensorType", referenced from:
std::__1::vector<float, std::__1::allocator > cppflow::tensor::get_data() const in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: clangclang: : clang: clang: error: error: linker command failed with exit code 1 (use -v to see invocation)linker command failed with exit code 1 (use -v to see invocation)error:
error:
linker command failed with exit code 1 (use -v to see invocation)
linker command failed with exit code 1 (use -v to see invocation)
error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [examples/multi_input_output/multi_input_output] Error 1
make[2]: *** [examples/load_model/load_model] Error 1
make[2]: *** [examples/efficientnet/efficientnet] Error 1
make[2]: *** [examples/tensor/tensor] Error 1
make[2]: *** [examples/eager_op_multithread/eager_op_multithread] Error 1
make[1]: *** [examples/load_model/CMakeFiles/load_model.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [examples/multi_input_output/CMakeFiles/multi_input_output.dir/all] Error 2
make[1]: *** [examples/tensor/CMakeFiles/tensor.dir/all] Error 2
make[1]: *** [examples/efficientnet/CMakeFiles/efficientnet.dir/all] Error 2
make[1]: *** [examples/eager_op_multithread/CMakeFiles/eager_op_multithread.dir/all] Error 2
make: *** [all] Error 2

I see.

What version of TF C API are you using?

I don't know. I only have linux and cpu-linux-x86_64-2.8.0 works fine in my computer. I think is some issue with the MacOS compiler. Have you checked this?

commented

Same error on my ubuntu system too with cpu-linux-x86_64-2.8.0 version of the C API.

commented

I have the same error :
git clone https://github.com/serizba/cppflow.git
Cloning into 'cppflow'...
remote: Enumerating objects: 1011, done.
remote: Counting objects: 100% (313/313), done.
remote: Compressing objects: 100% (139/139), done.
remote: Total 1011 (delta 195), reused 250 (delta 170), pack-reused 698
Receiving objects: 100% (1011/1011), 8.70 MiB | 5.32 MiB/s, done.
Resolving deltas: 100% (483/483), done.
Checking connectivity... done.
root@amax:/data/tenforflow# date
2023年 02月 15日 星期三 17:40:31 CST
root@amax:/data/tenforflow# cd cppflow/examples/load_model
root@amax:/data/tenforflow/cppflow/examples/load_model# mkdir build
root@amax:/data/tenforflow/cppflow/examples/load_model# cd build/
root@amax:/data/tenforflow/cppflow/examples/load_model/build# cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /data/tenforflow/cppflow/examples/load_model/build
root@amax:/data/tenforflow/cppflow/examples/load_model/build# make -j
[ 50%] Building CXX object CMakeFiles/load_model.dir/main.cpp.o
/data/tenforflow/cppflow/examples/load_model/main.cpp:36:25: fatal error: cppflow/ops.h: No such file or directory
compilation terminated.
CMakeFiles/load_model.dir/build.make:75: recipe for target 'CMakeFiles/load_model.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/load_model.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/load_model.dir/all' failed
make[1]: *** [CMakeFiles/load_model.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

commented

I have the same error : git clone https://github.com/serizba/cppflow.git Cloning into 'cppflow'... remote: Enumerating objects: 1011, done. remote: Counting objects: 100% (313/313), done. remote: Compressing objects: 100% (139/139), done. remote: Total 1011 (delta 195), reused 250 (delta 170), pack-reused 698 Receiving objects: 100% (1011/1011), 8.70 MiB | 5.32 MiB/s, done. Resolving deltas: 100% (483/483), done. Checking connectivity... done. root@amax:/data/tenforflow# date 2023年 02月 15日 星期三 17:40:31 CST root@amax:/data/tenforflow# cd cppflow/examples/load_model root@amax:/data/tenforflow/cppflow/examples/load_model# mkdir build root@amax:/data/tenforflow/cppflow/examples/load_model# cd build/ root@amax:/data/tenforflow/cppflow/examples/load_model/build# cmake .. -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.5s) -- Generating done (0.0s) -- Build files have been written to: /data/tenforflow/cppflow/examples/load_model/build root@amax:/data/tenforflow/cppflow/examples/load_model/build# make -j [ 50%] Building CXX object CMakeFiles/load_model.dir/main.cpp.o /data/tenforflow/cppflow/examples/load_model/main.cpp:36:25: fatal error: cppflow/ops.h: No such file or directory compilation terminated. CMakeFiles/load_model.dir/build.make:75: recipe for target 'CMakeFiles/load_model.dir/main.cpp.o' failed make[2]: *** [CMakeFiles/load_model.dir/main.cpp.o] Error 1 CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/load_model.dir/all' failed make[1]: *** [CMakeFiles/load_model.dir/all] Error 2 Makefile:90: recipe for target 'all' failed make: *** [all] Error 2

copy header file: cp -rf cppflow/include/cppflow /usr/local/include ; worked
### then try make again:
cppflow/examples/load_model/build# make
[ 50%] Building CXX object CMakeFiles/load_model.dir/main.cpp.o
In file included from /usr/include/c++/5/type_traits:35:0,
from /usr/local/include/cppflow/datatype.h:39,
from /usr/local/include/cppflow/tensor.h:52,
from /usr/local/include/cppflow/ops.h:38,
from /data/tenforflow/cppflow/examples/load_model/main.cpp:36:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support
^
In file included from /usr/local/include/cppflow/tensor.h:51:0,
from /usr/local/include/cppflow/ops.h:38,
from /data/tenforflow/cppflow/examples/load_model/main.cpp:36:
/usr/local/include/cppflow/context.h:57:18: error: expected ‘,’ or ‘...’ before ‘&&’ token
context(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:57:20: error: invalid constructor; you probably meant ‘cppflow::context (const cppflow::context&)’
context(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:57:20: error: expected ‘;’ at end of member declaration
/usr/local/include/cppflow/context.h:57:22: error: ‘noexcept’ does not name a type
context(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:57:22: note: C++11 ‘noexcept’ only available with -std=c++11 or -std=gnu++11
/usr/local/include/cppflow/context.h:62:29: error: expected ‘,’ or ‘...’ before ‘&&’ token
context& operator=(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:62:31: error: expected ‘;’ at end of member declaration
context& operator=(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:62:33: error: ‘noexcept’ does not name a type
context& operator=(context&&) noexcept;
^
/usr/local/include/cppflow/context.h:62:33: note: C++11 ‘noexcept’ only available with -std=c++11 or -std=gnu++11
/usr/local/include/cppflow/context.h:54:47: error: ‘nullptr’ was not declared in this scope
explicit context(TFE_ContextOptions* opts = nullptr);
^
/usr/local/include/cppflow/context.h:70:28: error: ‘nullptr’ was not declared in this scope
TFE_Context* tfe_context{nullptr};
^
/usr/local/include/cppflow/context.h:70:35: error: cannot convert ‘’ to ‘TFE_Context*’ in initialization
TFE_Context* tfe_context{nullptr};
^
/usr/local/include/cppflow/context.h: In function ‘cppflow::context& cppflow::get_global_context()’:
/usr/local/include/cppflow/context.h:78:20: error: call to ‘cppflow::context::context(TFE_ContextOptions*)’ uses the default argument for parameter 1, which is not yet defined
static context global_context;
^
/usr/local/include/cppflow/context.h: In static member function ‘static TF_Status* cppflow::context::get_status()’:
/usr/local/include/cppflow/context.h:90:3: error: ‘thread_local’ was not declared in this scope
thread_local std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)>
^
/usr/local/include/cppflow/context.h:92:10: error: ‘local_tf_status’ was not declared in this scope
return local_tf_status.get();
^
/usr/local/include/cppflow/context.h: In constructor ‘cppflow::context::context(TFE_ContextOptions*)’:
/usr/local/include/cppflow/context.h:96:8: error: ‘tf_status’ does not name a type
auto tf_status = context::get_status();
^
/usr/local/include/cppflow/context.h:97:15: error: ‘nullptr’ was not declared in this scope
if (opts == nullptr) {
^
/usr/local/include/cppflow/context.h:98:5: error: ‘unique_ptr’ is not a member of ‘std’
std::unique_ptr<TFE_ContextOptions, decltype(&TFE_DeleteContextOptions)>
^
/usr/local/include/cppflow/context.h:98:39: error: expected primary-expression before ‘,’ token
std::unique_ptr<TFE_ContextOptions, decltype(&TFE_DeleteContextOptions)>
^
/usr/local/include/cppflow/context.h:98:75: error: ‘decltype’ was not declared in this scope
std::unique_ptr<TFE_ContextOptions, decltype(&TFE_DeleteContextOptions)>
^
/usr/local/include/cppflow/context.h:99:68: error: ‘new_opts’ was not declared in this scope
new_opts(TFE_NewContextOptions(), &TFE_DeleteContextOptions);
^
/usr/local/include/cppflow/context.h💯56: error: ‘tf_status’ was not declared in this scope
this->tfe_context = TFE_NewContext(new_opts.get(), tf_status);
^
/usr/local/include/cppflow/context.h:102:46: error: ‘tf_status’ was not declared in this scope
this->tfe_context = TFE_NewContext(opts, tf_status);
^
/usr/local/include/cppflow/context.h:104:16: error: ‘tf_status’ was not declared in this scope
status_check(tf_status);
^
/usr/local/include/cppflow/context.h: At global scope:
/usr/local/include/cppflow/context.h:107:32: error: expected ‘,’ or ‘...’ before ‘&&’ token
inline context::context(context&& ctx) noexcept
^
/usr/local/include/cppflow/context.h:107:40: error: expected initializer before ‘noexcept’
inline context::context(context&& ctx) noexcept
^
/usr/local/include/cppflow/context.h:110:43: error: expected ‘,’ or ‘...’ before ‘&&’ token
inline context& context::operator=(context&& ctx) noexcept {
^
/usr/local/include/cppflow/context.h:110:51: error: expected initializer before ‘noexcept’
inline context& context::operator=(context&& ctx) noexcept {
^
In file included from /usr/local/include/cppflow/tensor.h:52:0,
from /usr/local/include/cppflow/ops.h:38,
from /data/tenforflow/cppflow/examples/load_model/main.cpp:36:
/usr/local/include/cppflow/datatype.h:43:7: error: expected nested-name-specifier before ‘datatype’
using datatype = TF_DataType;
^
/usr/local/include/cppflow/datatype.h:48:30: error: ‘cppflow::to_string’ declared as an ‘inline’ variable
inline std::string to_string(datatype dt) {
^
/usr/local/include/cppflow/datatype.h:48:30: error: ‘datatype’ was not declared in this scope
/usr/local/include/cppflow/datatype.h:48:43: error: expected ‘,’ or ‘;’ before ‘{’ token
inline std::string to_string(datatype dt) {
^
/data/tenforflow/cppflow/examples/load_model/main.cpp:55:1: error: expected ‘}’ at end of input
}
^
CMakeFiles/load_model.dir/build.make:75: recipe for target 'CMakeFiles/load_model.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/load_model.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/load_model.dir/all' failed
make[1]: *** [CMakeFiles/load_model.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2