geusfexx
geusfexx

Reputation: 41

/usr/include/stdlib.h:133:35: error: missing binary operator before token "("

I have a preprocess error for compiling gtest project with tizen headers on gitlab ci-runners (Debian GNU/Linux 10 (buster)). gcc (Debian 8.3.0-6) 8.3.0

But on local machine Ubuntu 16.04 compiles this successfully. gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609

I have an installed Tizen Studion 4.1 with SDK: WEARABLE-5.5 and knox_add_on_sdk_2.5.0. Exported env PATH to tools/ide/bin and package-manager, and tizen_include_root

To reproduce problem you should use #include <tizen.h> in project which used by gtest and absolute path to tizen headers in include_directories(...

cmake_minimum_required(VERSION 3.5)
project(tests)

set (CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")

include_directories(
#Tizen headers
    if(DEFINED ENV{TIZEN_SDK_HOME})
        SET(tizen_include_root "$ENV{TIZEN_SDK_HOME}/platforms/tizen-5.5/wearable/rootstraps/wearable-5.5-emulator.core/usr/include")
        ${tizen_include_root}/*
    else()
        message(WARNING "TIZEN_SDK_HOME env variable is not defined: tizen specific code completion and other features might not work")
    endif()
)

include_directories(BEFORE
        googletest/include

errors like this:

Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /usr/include/c++/8/cstdlib:75,
                 from /usr/include/c++/8/ext/string_conversions.h:41,
                 from /usr/include/c++/8/bits/basic_string.h:6400,
                 from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bits/locale_classes.h:40,
                 from /usr/include/c++/8/bits/ios_base.h:41,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from **DELETED**/src/test/googletest/include/gtest/gtest.h:56,
                 from **DELETED**/src/test/googletest/src/gtest-all.cc:38:
/usr/include/stdlib.h:133:35: error: missing binary operator before token "("
 #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
                                   ^
/usr/include/stdlib.h:139:35: error: missing binary operator before token "("
 #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
                                   ^
/usr/include/stdlib.h:145:35: error: missing binary operator before token "("
 #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)

or this:

In file included from /usr/include/x86_64-linux-gnu/bits/types/locale_t.h:22,
                 from /usr/include/stdlib.h:272,
                 from /usr/include/c++/8/cstdlib:75,
                 from /usr/include/c++/8/ext/string_conversions.h:41,
                 from /usr/include/c++/8/bits/basic_string.h:6400,
                 from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bits/locale_classes.h:40,
                 from /usr/include/c++/8/bits/ios_base.h:41,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from **DELETED**/src/test/googletest/include/gtest/gtest.h:56,
                 from **DELETED**/src/test/googletest/src/gtest-all.cc:38:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:28:8: error: redefinition of 'struct __locale_struct'
 struct __locale_struct

How can I separate tizen and system headers and which should I use?

Upvotes: 2

Views: 2837

Answers (1)

geusfexx
geusfexx

Reputation: 41

Problem solved. Using the direct path to the compiler in CMakeList.txt helped me.

if(DEFINED ENV{TIZEN_SDK_HOME})
    set(CMAKE_CXX_COMPILER $ENV{TIZEN_SDK_HOME}/tools/i586-linux-gnueabi-gcc-6.2/bin/i586-linux-gnueabi-g++)

You should use FLAGS with --sysroot and -L to tizen's libs

SET(gcc_root "$ENV{TIZEN_SDK_HOME}/platforms/tizen-5.5/wearable/rootstraps/wearable-5.5-emulator.core")

set(CMAKE_C_FLAGS "--std=c99 ${CMAKE_C_FLAGS}")
set(CMAKE_C_STANDARD 99)
set (CMAKE_CXX_FLAGS "--std=c++14 --sysroot=${gcc_root} -L${gcc_root}/lib -L${gcc_root}/usr/lib ${CMAKE_CXX_FLAGS}")

Also LDFLAGS is needed

export gcc_root=${TIZEN_SDK_HOME}/platforms/tizen-5.5/wearable/rootstraps/wearable-5.5-emulator.core
export LDFLAGS="--sysroot=${gcc_root} -L${gcc_root}/lib -L${gcc_root}/usr/lib"

Upvotes: 2

Related Questions