incomplete type `std::string' when building OSDK on Raspberry Pi 4 - cmake

I am trying to build the DJI Onboard-SDK on a Raspberry Pi 4, and have had errors with different libraries missing that I have managed to resolve by installing those libraries. I've now gotten an error saying std::string isan incomplete type and printf is not declared. The only suggestions I've found say to install build-essentials, which I've already got installed and up to date. Can anyone give me suggestions about where to look next?
I've tried reinstalling g++ and ensuring all packages are up to date. I'm still getting the following errors in my make output;
[ 26%] Building CXX object osdk-core/CMakeFiles/djiosdk-core.dir/modules/src/filemgr/impl/mmap_file_buffer.cpp.o
In file included from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:23:15: error: field ‘currentLogFilePath’ has incomplete type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
23 | std::string currentLogFilePath;
| ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/iosfwd:39,
from /usr/include/c++/10/memory:74,
from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:13,
from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
74 | class basic_string;
| ^~~~~~~~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:15:39: error: ‘path’ has incomplete type
15 | bool MmapFileBuffer::init(std::string path, uint64_t fileSize) {
| ~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/iosfwd:39,
from /usr/include/c++/10/memory:74,
from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:13,
from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
74 | class basic_string;
| ^~~~~~~~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp: In member function ‘bool DJI::OSDK::MmapFileBuffer::init(std::string, uint64_t)’:
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:19:3: error: ‘printf’ was not declared in this scope
19 | printf("Preparing File : %s\n", this->currentLogFilePath.c_str());
| ^~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:7:1: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
6 | #include <string.h>
+++ |+#include <cstdio>
7 |
make[2]: *** [osdk-core/CMakeFiles/djiosdk-core.dir/build.make:524: osdk-core/CMakeFiles/djiosdk-core.dir/modules/src/filemgr/impl/mmap_file_buffer.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:580: osdk-core/CMakeFiles/djiosdk-core.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

Related

__uint128 does not name a type

I am trying to compile cmake-3.21.4 on aarch64-linux-gnu. I get the following error
e/root/cmake-3.21.4/Utilities -c /home/root/cmake-3.21.4/Source/cmUVHandlePtr.cxx -o cmUVHandlePtr.o
In file included from /usr/include/bits/sigcontext.h:30,
from /usr/include/signal.h:301,
from /usr/include/sys/param.h:28,
from /home/root/cmake-3.21.4/Utilities/cmlibuv/include/uv/unix.h:41,
from /home/root/cmake-3.21.4/Utilities/cmlibuv/include/uv.h:70,
from /home/root/cmake-3.21.4/Utilities/cm3p/uv.h:10,
from /home/root/cmake-3.21.4/Source/cmUVHandlePtr.h:11,
from /home/root/cmake-3.21.4/Source/cmUVHandlePtr.cxx:4:
/usr/include/c++/11.2.0/bits/std_abs.h:84:29: error: '__uint128' does not name a type; did you mean '__int128'?
84 | inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11.2.0/chrono:41,
from /usr/include/c++/11.2.0/mutex:39,
from /home/root/cmake-3.21.4/Source/cmUVHandlePtr.cxx:8:
/usr/include/c++/11.2.0/limits:1635:11: error: '__uint128' was not declared in this scope; did you mean '__int128'?
1635 | __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11.2.0/limits:1635:3: error: template argument 1 is invalid
1635 | __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
| ^~~~~~~
/usr/include/c++/11.2.0/limits:1635:3: error: template argument 1 is invalid
1635 | __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
| ^~~~~~~
I have searched through cmake source for __uint128 with no result. It's probably an issue with my c++ includes or gcc. What should I Do?
I had almost the same problem, the solution for me was to paste this code into the file that gave error:
typedef unsigned __int128 __uint128;
This code simply declares __uint128

Building flipper contract

I am following this tutorial https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract but am getting the following error. Does anyone know how to resolve this?
➜ flipper cargo +nightly contract build
[1/5] Building cargo project
Updating crates.io index
Compiling flipper v0.1.0 (/tmp/cargo-contract_dLtaWE)
error[E0277]: the trait bound `__ink_ConstructorDispatchEnum: parity_scale_codec::codec::WrapperTypeDecode` is not satisfied
--> /home/bill/flipper/lib.rs:5:1
|
5 | #[ink::contract]
| ^^^^^^^^^^^^^^^^ the trait `parity_scale_codec::codec::WrapperTypeDecode` is not implemented for `__ink_ConstructorDispatchEnum`
|
::: /home/bill/.cargo/registry/src/github.com-1ecc6299db9ec823/ink_env-3.0.0-rc3/src/api.rs:465:8
|
465 | T: scale::Decode,
| ------------- required by this bound in `decode_input`
|
= note: required because of the requirements on the impl of `parity_scale_codec::codec::Decode` for `__ink_ConstructorDispatchEnum`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `__ink_MessageDispatchEnum: parity_scale_codec::codec::WrapperTypeDecode` is not satisfied
--> /home/bill/flipper/lib.rs:5:1
|
5 | #[ink::contract]
| ^^^^^^^^^^^^^^^^ the trait `parity_scale_codec::codec::WrapperTypeDecode` is not implemented for `__ink_MessageDispatchEnum`
|
::: /home/bill/.cargo/registry/src/github.com-1ecc6299db9ec823/ink_env-3.0.0-rc3/src/api.rs:465:8
|
465 | T: scale::Decode,
| ------------- required by this bound in `decode_input`
|
= note: required because of the requirements on the impl of `parity_scale_codec::codec::Decode` for `__ink_MessageDispatchEnum`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `flipper`
To learn more, run the command again with --verbose.
ERROR: `"/home/bill/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "build" "--target=wasm32-unknown-unknown" "-Zbuild-std" "-Zbuild-std-features=panic_immediate_abort" "--no-default-features" "--release" "--target-dir=/home/bill/flipper/target"` failed with exit code: Some(101)

compiling Opensips on Clion: missing tap.h, which library is missing?

I am trying to compile Opensips on Clion as I want to debug and step through the code. I have tried adding environment variables through following lines in CMakeLists.txt:
set(CMAKE_C_FLAGS "-funroll-loops -Wcast-align -Wall -minline-all-stringops -falign-loops -ftree-vectorize -mtune=nocona -Wold-style-definition -Wmissing-field-initializers -Wredundant-decls" )
add_definitions(-DPKG_MALLOC -DSHM_MMAP -DUSE_MCAST -DDISABLE_NAGLE -DSTATISTICS -DHAVE_RESOLV_RES -DF_MALLOC -DF_MALLOC_OPTIMIZATIONS -DNAME='"opensips"' -DVERSION='"2.4.2"' -DARCH='"x86_64"' -DOS='"linux"' -DCOMPILER='"gcc 4.8.5"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes -DCFG_DIR='"/usr/local//etc/opensips/"' -DVERSIONTYPE='"git"' -DTHISREVISION='"c035556"' -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT)
===========================================================
I get following errors and I am not sure which package is missing:
-- Build files have been written to: /root/opensips-2.4/cmake-build-debug
[ 0%] Building C object CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o
[ 0%] Building C object CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o
/root/opensips-2.4/cachedb/test/test_backends.c:21:17: fatal error: tap.h: No such file or directory
include
^
compilation terminated.
gmake[2]: * [CMakeFiles/opensips_2_4.dir/cachedb/test/test_backends.c.o] Error 1
gmake[2]: * Waiting for unfinished jobs....
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default]
MODULE_VERSION,
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: initialization makes pointer from integer without a cast [enabled by default]
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: (near initialization for ‘exports.version’) [enabled by default]
In file included from /root/opensips-2.4/cachedb/example/../../sr_module.h:52:0,
from /root/opensips-2.4/cachedb/example/example_cachedb.c:32:
/root/opensips-2.4/cachedb/example/../../version.h:26:37: error: expected ‘}’ before string constant
define OPENSIPS_FULL_VERSION NAME " " VERSION " (" ARCH "/" OS ")"
^
/root/opensips-2.4/cachedb/example/../../sr_module.h:102:2: note: in expansion of macro ‘OPENSIPS_FULL_VERSION’
OPENSIPS_FULL_VERSION,
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: note: in expansion of macro ‘MODULE_VERSION’
MODULE_VERSION,
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default]
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default]
/root/opensips-2.4/cachedb/example/example_cachedb.c:75:2: warning: character constant too long for its type [enabled by default]
/root/opensips-2.4/cachedb/example/example_cachedb.c:89:1: warning: missing initializer for field ‘compile_flags’ of ‘struct module_exports’ [-Wmissing-field-initializers]
};
^
In file included from /root/opensips-2.4/cachedb/example/example_cachedb.c:32:0:
/root/opensips-2.4/cachedb/example/../../sr_module.h:175:8: note: ‘compile_flags’ declared here
char compile_flags; /!< compile flags used on the module /
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:95:12: warning: ‘mod_init’ defined but not used [-Wunused-function]
static int mod_init(void)
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:137:12: warning: ‘child_init’ defined but not used [-Wunused-function]
static int child_init(int rank)
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:154:13: warning: ‘destroy’ defined but not used [-Wunused-function]
static void destroy(void)
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:59:21: warning: ‘cmds’ defined but not used [-Wunused-variable]
static cmd_export_t cmds[]=
^
/root/opensips-2.4/cachedb/example/example_cachedb.c:65:23: warning: ‘params’ defined but not used [-Wunused-variable]
static param_export_t params[]={
^
gmake[2]: [CMakeFiles/opensips_2_4.dir/cachedb/example/example_cachedb.c.o] Error 1
gmake[1]: * [CMakeFiles/opensips_2_4.dir/all] Error 2
gmake: *** [all] Error 2
The tap.h error is due to the fact that you have enabled unit-testing support in your build, via the -DUNIT_TESTS flag in Makefile.conf. If you still want to go down this route and run the cachedb-related unit tests for MongoDB/Cassandra:
download libtap, from here
make and sudo make install

Does g++ contain the functional library?

I have problems with using functional in g++. I compile with !g++ -o test test.cpp -std=c++11 and it does not give any errors and the program also runs fine. I use Syntastic to check any errors before compiling, and it gives me the following output.
This is my program test.cpp:
1 #include <functional>
2
3 using namespace std;
4
5 int f(int x){
6 return x;
7 }
8
9 void f2(function<int(int)> f){
10
11 }
12
13 int main(){
14 return 0;
15 }
The error is:
1 test.cpp|9 col 9 error| variable or field ‘f2’ declared void
2 test.cpp|9 col 9 error| ‘function’ was not declared in this scope
3 test.cpp|9 col 18 error| expected primary-expression before ‘int’
What does this error mean and how do I fix it?
The problem was that Syntastic was not checking c++11 code since functional can only be used with c++11. That was the reason the compiling went fine and the output file displayed correct results.
I found the answer in this question after discovering the root of the problem:
how to add c++11 support to syntastic vim plugin?
so I just had to add
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
to my vimrc

Error when Make CLucene

I'm using a MBP OSX(10.9) and is new to CLucene and I'm having problem installing it. Despite following the installation guide closely, I still hit these errors while making the file
[ 0%] Building CXX object src/shared/CMakeFiles/clucene-shared.dir/CLucene/SharedHeader.o
In file included from /Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/SharedHeader.cpp:8:
In file included from /Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/_SharedHeader.h:13:
In file included from /Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/SharedHeader.h:201:
In file included from /Users/youhock/Downloads/clucene-core-2.3.3.4/src/core/CLucene/debug/lucenebase.h:10:
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:56:19: error:
unknown type name 'pthread_t'
static _LUCENE_THREADID_TYPE _GetCurrentThreadId();
^
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:40:41: note:
expanded from macro '_LUCENE_THREADID_TYPE'
#define _LUCENE_THREADID_TYPE pthread_t
^
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:57:18: error:
unknown type name 'pthread_t'
static _LUCENE_THREADID_TYPE CreateThread(lucene...
^
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:40:41: note:
expanded from macro '_LUCENE_THREADID_TYPE'
#define _LUCENE_THREADID_TYPE pthread_t
^
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:58:34: error:
unknown type name 'pthread_t'
static void JoinThread(_LUCENE_THREADID_TYPE id);
^
/Users/youhock/Downloads/clucene-core-2.3.3.4/src/shared/CLucene/LuceneThreads.h:40:41: note:
expanded from macro '_LUCENE_THREADID_TYPE'
#define _LUCENE_THREADID_TYPE pthread_t
^
3 errors generated.
make[2]: *** [src/shared/CMakeFiles/clucene-shared.dir/CLucene/SharedHeader.o] Error 1
make[1]: *** [src/shared/CMakeFiles/clucene-shared.dir/all] Error 2
make: *** [all] Error 2
Appreciate if anyone could help me with this? Thanks in advance
Have a look at my other answer.
Bascially you have to patch
src/shared/CLucene/LuceneThreads.h
src/shared/CLucene/config/repl_tchar.h
The other post contains the links as well.