I'm developing an OpenCV project that will run on a raspberry pi. So far I have been developing on a Mac in Xcode and all is going well. I recently realized that in order to tap into the raspberry pi camera I will need to use the raspicam library.
My question is, can I install raspicam libraries on OS X or are they raspberry pi hardware specific?
I would like to be able to develop, compile, and build on my Mac as well as compile and build on the raspberry pi. I am trying to avoid doing my development on the Pi.
If that's not possible do you have any recommendations for how I should manage the development setup for this project?
There is only a small section of my code that requires the raspicam libraries so I am not opposed to having a flag that executes the raspicam code if running on the Pi, otherwise executes the currently working OpenCV code if running on the Mac.
So far I have downloaded the raspicam source and I have done:
cd raspicam-0.1.3
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV" ..
And here is the output:
-- Adding cv library
--
-- -------------------------------------------------------------------------------
-- General configuration for raspicam 0.1.2
-- -------------------------------------------------------------------------------
--
Built as dynamic libs?:ON
Compiler:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- C++ flags (Release): -std=c++0x -Wl,--no-as-needed -lpthread
-- C++ flags (Debug): -std=c++0x -Wl,--no-as-needed -lpthread
-- CMAKE_CXX_FLAGS: -std=c++0x -Wl,--no-as-needed
-- CMAKE_BINARY_DIR: /Users/andres/Downloads/raspicam-0.1.3/build
--
-- CMAKE_SYSTEM_PROCESSOR = x86_64
-- BUILD_SHARED_LIBS = ON
-- BUILD_UTILS = ON
-- CMAKE_INSTALL_PREFIX = /usr/local
-- CMAKE_BUILD_TYPE = Release
-- CMAKE_MODULE_PATH = /usr/local/lib/cmake/;/usr/lib/cmake
--
-- CREATE OPENCV MODULE=1
-- CMAKE_INSTALL_PREFIX=/usr/local
-- REQUIRED_LIBRARIES=
--
--
-- Change a value with: cmake -D<Variable>=<Value>
--
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
raspicam
raspicam_cv
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Users/andres/Downloads/raspicam-0.1.3/build
Then
make
Output:
Scanning dependencies of target raspicam_cv
[ 5%] Building CXX object src/CMakeFiles/raspicam_cv.dir/raspicam_cv.cpp.o
clang: warning: -Wl,--no-as-needed: 'linker' input unused
clang: warning: -lpthread: 'linker' input unused
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:297:22: error:
use of undeclared identifier 'CLOCK_REALTIME'
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
^
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:307:13: error:
use of undeclared identifier 'sem_timedwait'
ret = sem_timedwait( sem, &ts );
^
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:327:13: warning:
'sem_init' is deprecated [-Wdeprecated-declarations]
int rc = sem_init(sem, 0, initial_count);
^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked
deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:335:13: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
int rc = sem_destroy(sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:520:13: warning:
'sem_init' is deprecated [-Wdeprecated-declarations]
int rc = sem_init(&event->sem, 0, 0);
^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked
deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:525:7: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
sem_destroy(&event->sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:541:8: warning:
'sem_getvalue' is deprecated [-Wdeprecated-declarations]
if (sem_getvalue(&event->sem, &value) != 0)
^
/usr/include/sys/semaphore.h:54:5: note: 'sem_getvalue' has been explicitly
marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
^
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/raspicam_cv.cpp:39:
In file included from /Users/andres/Downloads/raspicam-0.1.3/src/./private/private_impl.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal.h:363:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/mmal/mmal_common.h:40:
In file included from /Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/vcos.h:116:
/Users/andres/Downloads/raspicam-0.1.3/dependencies/vcos/pthreads/vcos_platform.h:582:13: warning:
'sem_destroy' is deprecated [-Wdeprecated-declarations]
int rc = sem_destroy(&event->sem);
^
/usr/include/sys/semaphore.h:53:5: note: 'sem_destroy' has been explicitly
marked deprecated here
int sem_destroy(sem_t *) __deprecated;
^
6 warnings and 2 errors generated.
make[2]: *** [src/CMakeFiles/raspicam_cv.dir/raspicam_cv.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/raspicam_cv.dir/all] Error 2
make: *** [all] Error 2
The solution I came up with was to use:
#ifdef __ARM__
include <raspicam/raspicam.h>
#endif
and in the main
#ifdef __ARM__
// pi specific camera initialization code
#elif __APPLE__
// osx specific camera initialization code
#endif
These preprocessors will be evaluated before the code is compiled. If the source is being compiled on the pi (ARM architecture) the __ARM__ sections will be compiled, otherwise if the source code is being compiled on osx the __APPLE__ sections will be compiled.
Related
I'm working on an mbed application and I want to be able to unit test some of the functionality. I created a test app so I could try out unit testing and I can't seem to get it to build. The TLDR of it is when I go to build the app the build fails with errors like:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_core_c.h:42:2: error: #error "Unknown Arm Architecture!"
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2015:40: error: 'fileno' was not declared in this scope; did you mean 'file'?
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2021:47: error: 'strdup' was not declared in this scope; did you mean 'StrDup'?
The more detailed version of it, on Windows I created a new app by:
1. mbed-tools new
2. mbed-tools configure -m K64F -t GCC_ARM
Then I created a simple class to be tested MyClass.h and MyClass.cpp
#include "MyClass.h"
MyClass::MyClass() { }
bool MyClass::IsTwo(int number) {
return number == 2;
}
And then also a simple test file UNITTESTS\test_MyClass.cc
#include "gtest/gtest.h"
#include "../MyClass.h"
class TestMyClass : public testing::Test {
protected:
MyClass *cls;
void SetUp(){
cls = new MyClass();
}
void TearDown(){
delete cls;
}
};
TEST_F(TestMyClass, test_isTwo){
EXPECT_TRUE(cls->IsTwo(2));
EXPECT_FALSE(cls->IsTwo(23));
}
Then following the instructions from Google found here I edited my root CMakeList.txt to be
# Copyright (c) 2022 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.19.0)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET gtest_example)
include(${MBED_PATH}/tools/cmake/app.cmake)
project(${APP_TARGET})
# Disable tests as default configuration, use -DBUILD_TESTING to enable
option(BUILD_TESTING "Run mbed os UNITTESTS" ON)
add_subdirectory(${MBED_PATH})
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(${MBED_PATH}/UNITTESTS) # add mbed os stubs and fakes
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/UNITTESTS)
endif()
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent projects compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
add_executable(${APP_TARGET}
main.cpp
MyClass.cpp MyClass.h
)
target_link_libraries(${APP_TARGET} mbed-os)
mbed_set_post_build(${APP_TARGET})
option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
and the UNITTESTS\CMakeLists.txt file to be
set(TEST_NAME example-unittest)
enable_testing()
add_executable(${TEST_NAME}
test_MyClass.cc
)
target_link_libraries(${TEST_NAME}
GTest::gtest_main
)
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})
Then I ran
cmake -S . -B cmake_build\K64F\develop\GCC_ARM -GNinja -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS=-std=c++14
resulting in
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gcc.exe - 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: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: C:/Python39/python.exe (found version "3.9.7") found components: Interpreter
-- Checking for Python package prettytable -- found
-- Checking for Python package future -- found
-- Checking for Python package jinja2 -- found
-- Checking for Python package intelhex -- found
-- Found Python: C:/Python39/python.exe (found version "3.9.7") found components: Interpreter
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- Could NOT find Threads (missing: Threads_FOUND)
-- Could NOT find Threads (missing: Threads_FOUND)
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM
and then finally I ran
cmake --build cmake_build\K64F\develop\GCC_ARM
which fails with a bunch of errors
[75/208] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj
FAILED: _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #_deps\googletest-build\googletest\CMakeFiles\gtest_main.dir\src\gtest_main.cc.obj.rsp -MD -MT _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj -MF _deps\googletest-build\googletest\CMakeFiles\gtest_main.dir\src\gtest_main.cc.obj.d -o _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj -c C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/src/gtest_main.cc
In file included from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/gtest-message.h:55,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/gtest-assertion-result.h:46,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/gtest.h:59,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/src/gtest_main.cc:32:
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2015:40: error: 'fileno' was not declared in this scope; did you mean 'file'?
2015 | inline int FileNo(FILE* file) { return fileno(file); }
| ^~~~~~
| file
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2021:47: error: 'strdup' was not declared in this scope; did you mean 'StrDup'?
2021 | inline char* StrDup(const char* src) { return strdup(src); }
| ^~~~~~
| StrDup
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2065:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2065 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
[77/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\cmsis\device\rtos\source\mbed_rtx_idle.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\cmsis\device\rtos\source\mbed_rtx_idle.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/internal/SysTimer.h:21,
from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/internal/mbed_os_timer.h:21,
from C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp:27:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_lib.h:31,
from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/internal/mbed_os_timer.h:25,
from C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/device/rtos/source/mbed_rtx_idle.cpp:27:
C:/Users/chris/Desktop/gtest_example/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_core_c.h:42:2: error: #error "Unknown Arm Architecture!"
42 | #error "Unknown Arm Architecture!"
| ^~~~~
[78/208] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj
FAILED: _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #_deps\googletest-build\googlemock\CMakeFiles\gmock_main.dir\src\gmock_main.cc.obj.rsp -MD -MT _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj -MF _deps\googletest-build\googlemock\CMakeFiles\gmock_main.dir\src\gmock_main.cc.obj.d -o _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj -c C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/src/gmock_main.cc
In file included from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/internal/gmock-port.h:57,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:49,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/gmock-actions.h:145,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/gmock.h:56,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/src/gmock_main.cc:32:
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2015:40: error: 'fileno' was not declared in this scope; did you mean 'file'?
2015 | inline int FileNo(FILE* file) { return fileno(file); }
| ^~~~~~
| file
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2021:47: error: 'strdup' was not declared in this scope; did you mean 'StrDup'?
2021 | inline char* StrDup(const char* src) { return strdup(src); }
| ^~~~~~
| StrDup
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2065:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2065 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
[79/208] Building CXX object CMakeFiles/gtest_example.dir/main.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/main.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\main.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/main.cpp.obj -MF CMakeFiles\gtest_example.dir\main.cpp.obj.d -o CMakeFiles/gtest_example.dir/main.cpp.obj -c C:/Users/chris/Desktop/gtest_example/main.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\analogin.h:25,
from C:/Users/chris/Desktop/gtest_example/mbed-os/mbed.h:63,
from C:/Users/chris/Desktop/gtest_example/main.cpp:6:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/mbed.h:75,
from C:/Users/chris/Desktop/gtest_example/main.cpp:6:
c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\mbedcrc.h:658:2: error: #error "Unknown ARM architecture for CRC optimization"
658 | #error "Unknown ARM architecture for CRC optimization"
| ^~~~~
[80/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/AnalogIn.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/AnalogIn.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\AnalogIn.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/AnalogIn.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\AnalogIn.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/AnalogIn.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/AnalogIn.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\analogin.h:25,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/AnalogIn.cpp:18:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[81/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SerialBase.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SerialBase.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\SerialBase.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SerialBase.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\SerialBase.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SerialBase.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/SerialBase.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_wait_api.h:21,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/SerialBase.cpp:18:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[82/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/FlashIAP.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/FlashIAP.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\FlashIAP.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/FlashIAP.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\FlashIAP.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/FlashIAP.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/FlashIAP.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\flashiap.h:30,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/FlashIAP.cpp:28:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[83/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/platform/cxxsupport/mstd_mutex.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/platform/cxxsupport/mstd_mutex.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\platform\cxxsupport\mstd_mutex.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/platform/cxxsupport/mstd_mutex.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\platform\cxxsupport\mstd_mutex.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/platform/cxxsupport/mstd_mutex.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/platform/cxxsupport/mstd_mutex.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\platform\cxxsupport\mstd_mutex:43,
from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/cxxsupport/mstd_mutex.cpp:18:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[84/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/I2C.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/I2C.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\I2C.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/I2C.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\I2C.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/I2C.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/I2C.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\i2c.h:26,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/I2C.cpp:18:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[85/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/MbedCRC.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/MbedCRC.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\MbedCRC.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/MbedCRC.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\MbedCRC.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/MbedCRC.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/MbedCRC.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\mbedcrc.h:29,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/MbedCRC.cpp:19:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/MbedCRC.cpp:19:
c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\mbedcrc.h:658:2: error: #error "Unknown ARM architecture for CRC optimization"
658 | #error "Unknown ARM architecture for CRC optimization"
| ^~~~~
[86/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/platform/source/DeepSleepLock.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/platform/source/DeepSleepLock.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\platform\source\DeepSleepLock.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/platform/source/DeepSleepLock.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\platform\source\DeepSleepLock.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/platform/source/DeepSleepLock.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/platform/source/DeepSleepLock.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/source/DeepSleepLock.cpp:20:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[87/208] Building CXX object CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SPI.cpp.obj
FAILED: CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SPI.cpp.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #CMakeFiles\gtest_example.dir\mbed-os\drivers\source\SPI.cpp.obj.rsp -MD -MT CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SPI.cpp.obj -MF CMakeFiles\gtest_example.dir\mbed-os\drivers\source\SPI.cpp.obj.d -o CMakeFiles/gtest_example.dir/mbed-os/drivers/source/SPI.cpp.obj -c C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/SPI.cpp
In file included from C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/SingletonPtr.h:24,
from c:\users\chris\desktop\gtest_example\mbed-os\drivers\include\drivers\spi.h:27,
from C:/Users/chris/Desktop/gtest_example/mbed-os/drivers/source/SPI.cpp:17:
C:/Users/chris/Desktop/gtest_example/mbed-os/platform/include/platform/mbed_atomic.h:95:2: error: #error "Unknown ARM architecture for exclusive access"
95 | #error "Unknown ARM architecture for exclusive access"
| ^~~~~
[88/208] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj
FAILED: _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj
C:\ProgramData\chocolatey\bin\ccache.exe C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE #_deps\googletest-build\googlemock\CMakeFiles\gmock.dir\src\gmock-all.cc.obj.rsp -MD -MT _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj -MF _deps\googletest-build\googlemock\CMakeFiles\gmock.dir\src\gmock-all.cc.obj.d -o _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj -c C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/src/gmock-all.cc
In file included from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/internal/gmock-port.h:57,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:49,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/gmock-actions.h:145,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/include/gmock/gmock.h:56,
from C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googlemock/src/gmock-all.cc:39:
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2015:40: error: 'fileno' was not declared in this scope; did you mean 'file'?
2015 | inline int FileNo(FILE* file) { return fileno(file); }
| ^~~~~~
| file
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2021:47: error: 'strdup' was not declared in this scope; did you mean 'StrDup'?
2021 | inline char* StrDup(const char* src) { return strdup(src); }
| ^~~~~~
| StrDup
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
C:/Users/chris/Desktop/gtest_example/cmake_build/K64F/develop/GCC_ARM/_deps/googletest-src/googletest/include/gtest/internal/gtest-port.h:2065:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2065 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
...
ninja: build stopped: subcommand failed.
If I see this correctly, you are basically trying to use ARM cross compiler to create an x86(_64) test application. Mixing those two can't work. Hence the root cause of your problems "Unknown ARM architecture for exclusive access".
What you need is a CMake project capable targetting multiple platforms - ARM for embedded target and x86 for unit tests. -DBUILD_TESTING switch you already use is a good one to distinguish between ARM and x86 toolchains in the CMake.
I would suggest to separate the building stage from the main project directory. Create a subdirectory named x86 and call cmake .. -DDBUILD_TESTING for unit tests. Please note the .. instead of . in the command.
Then create another directory arm and call cmake .. for cross compiling the target objects for ARM. Add additional cmake parameters to both as needed.
You need to use native Windows compiler instead of a
ARM cross compiler for the unit tests to work.
GCC- Apple clang version 11.0.3 (clang-1103.0.32.29) is giving me weird results when I try to run any C++/C program. For example, running this code:
#include <string>
#include <iostream>
int main()
{
std::string hello = "Hello world";
std::cout << hello << std::endl;
return 0;
}
I run with gcc or g++
gcc template.cpp -o template
It gives me this error
In file included from template.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:624:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/initializer_list:47:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stddef.h:50:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:29: error: variable has incomplete type 'struct _LIBCPP_TEMPLATE_VIS'
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:8: note: forward declaration of 'std::__1::_LIBCPP_TEMPLATE_VIS'
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:23:38: error: expected ';' after top level declarator
struct _LIBCPP_TEMPLATE_VIS nullptr_t
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__nullptr:46:52: error: unknown type name 'nullptr_t'
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
^
In file included from template.cpp:2:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:40:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/istream:163:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:140:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/locale:192:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:167:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:110:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:135:9: note: using declaration
using ::abs;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:169:44: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:112:44: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:135:9: note: using declaration
using ::abs;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:172:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:115:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:143:9: note: using declaration
using ::div;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:174:42: error: declaration conflicts with target of using declaration already in scope
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:117:42: note: target of using declaration
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:143:9: note: using declaration
using ::div;
^
7 errors generated.
I think I caused this when I was trying to copy some library header files to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
Now I am unable to compile any C++ program on my Mac. I can't understand how to fix this.
I tried installing llvm and adding it's path but nothing helps.
> brew install llvm
==> Installing dependencies for llvm: libffi
==> Installing llvm dependency: libffi
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.3.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libffi-3.3.catalina.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export CPPFLAGS="-I/usr/local/opt/libffi/include"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
==> Summary
đș /usr/local/Cellar/libffi/3.3: 16 files, 489.4KB
==> Installing llvm
==> Downloading https://homebrew.bintray.com/bottles/llvm-10.0.0_3.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ea/ea9b9f579df49499d9ab0084e10edecc5350298d6c5db399a1dabc8694dab7db?__gda__=exp=1587779777~hmac=fa0024a2581a685070cc1612da34abc29c53c8c352dce2f47c74d841c
######################################################################## 100.0%
==> Pouring llvm-10.0.0_3.catalina.bottle.tar.gz
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
==> Summary
đș /usr/local/Cellar/llvm/10.0.0_3: 7,055 files, 1GB
> echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
> export LDFLAGS="-L/usr/local/opt/llvm/lib"
> export CPPFLAGS="-I/usr/local/opt/llvm/include"
~
Current versions of installed Clang:
> gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
> g++ version
Well, I found a solution. Earlier I was using XCode Application and I messed up some library files when I was trying to copy header files to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
It turned so fatal that I was totally helpless. Neither my C++ or C code would compile, nor Node Applications would build due to gyp.
Apparently it some more errors, when I tried to reinstall few things and my homebrew gave a page full of errors with unbrewed header files.
Solution:
I removed Xcode Application, switched to Command line tool.
Removed llvm, and it worked.
You need to switch the XCode path, you do it by:
sudo xcode-select --switch /Library/Developer/CommandLineTools
You are good to go, and never mess up with the files inside SDK, else it will cost you hours of panic. Cheers.
I had to re-install the xcode tools for some weird reason...
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
I had similar issues building a meteor app that had a node-gyp dependency, in the end I was able to follow the instructions here to get the build to work
Specifically exporting this flag:
export LDFLAGS=-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
The failure looked like
> bufferutil#4.0.4 install /Users/ben.ritchie/Documents/dev/connect4/connect4mvp/node_modules/bufferutil
> node-gyp-build
CC(target) Release/obj.target/bufferutil/src/bufferutil.o
In file included from ../src/bufferutil.c:2:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:42:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
typedef __int64_t __darwin_blkcnt_t; /* total blocks */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_blksize_t; /* preferred block size */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_dev_t; /* dev_t */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
typedef __uint64_t __darwin_ino64_t; /* [???] Used for 64 bit inodes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint64_t.h:31:28: note: 'uint64_t' declared here
typedef unsigned long long uint64_t;
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:52:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
typedef __uint16_t __darwin_mode_t; /* [???] Some file attributes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_pid_t; /* [???] process and group IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_sigset_t; /* [???] signal set */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
typedef __int32_t __darwin_suseconds_t; /* [???] microseconds */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_uid_t; /* [???] user IDs */
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
typedef __uint32_t __darwin_useconds_t; /* [???] microseconds */
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:53:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h:30:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
#error architecture not supported
^
In file included from ../src/bufferutil.c:3:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/node_api.h:12:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api.h:24:
In file included from /Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/include/node/js_native_api_types.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include/stdint.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h:53:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t'
typedef __darwin_intptr_t intptr_t;
^
18 errors generated.
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.5.0.sgqk5k.nggn++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.0.0.1fm8up2.pjm8++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/node" "/Users/ben.ritchie/.meteor/packages/meteor-tool/.2.5.0.sgqk5k.nggn++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/ben.ritchie/Documents/dev/connect4/connect4mvp/node_modules/bufferutil
gyp ERR! node -v v12.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
Just change:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
I'm tring to conform a part of matlab source to C++. The matlab source calls a matlab lib named Manopt for params optimizing, So I found a lib in C++ named ROPTLIB(http://www.math.fsu.edu/ROPTLIB/) to realize the same optimization as Manopt.
The problem occured when I download ROPTLIB and try to run the example demo in ROPTLIB user manual. I wrote a CMakeLists.txt(as follow) to compile the lib source code, for there is no compiling tools in lib diretory(except matlab script, but I want the lib run in pure C++ environment in my ubuntu 14.04LTS). The package of lapack and blas are also link to project as you can see in CMakelists.txt.
I try to search the Problem both in google and other forums, but no one can help me. If you have any experience for debug locale_facets_nonio.tcc:918:22: error: expected unqualified-id before or ROPTLIB, printing it blow mat help me.
CmakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
SET(ProjectName TestProductExample)
PROJECT(${ProjectName})
FILE(GLOB_RECURSE all_files
"${CMAKE_CURRENT_SOURCE_DIR}/Solvers/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Others/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/*.cpp"
)
INCLUDE_DIRECTORIES(
"${CMAKE_CURRENT_SOURCE_DIR}/Solvers/"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/StieSumBrockett/"
"${CMAKE_CURRENT_SOURCE_DIR}/Others/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/Stiefel/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/Euclidean/"
"${CMAKE_CURRENT_SOURCE_DIR}/blas/"
"${CMAKE_CURRENT_SOURCE_DIR}/lapack/"
)
message(STATUS "add include_directories " ${INCLUDE_DIRECTORIES})
if(${CMAKE_COMPILER_IS_GNUCC})
message (STATUS "add c++11 flags")
add_definitions(-Wall -s -std=c++11 )
endif()
set(LIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/;${LIB}")
message (STATUS "blas and lapack lib is in ${LIB}")
add_executable(${ProjectName} ${CMAKE_CURRENT_SOURCE_DIR}/test/TestProductExample.cpp ${all_files})
link_directories({${LIB}})
target_link_libraries(${ProjectName} lapack_LINUX.a blas_LINUX.a tmglib_LINUX.a)
message (STATUS "CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}, CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_COMPILER_IS_GNUCC is ${CMAKE_COMPILER_IS_GNUCC}")`
error log:
[ 1%] Building CXX object CMakeFiles/TestProductExample.dir/test/TestProductExample.cpp.o
In file included from /usr/include/c++/4.7/bits/locale_facets_nonio.h:1903:0,
from /usr/include/c++/4.7/locale:43,
from /usr/include/c++/4.7/iomanip:45,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Manifolds/Manifold.h:23,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Problems/Problem.h:16,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/test/TestProductExample.cpp:20:
/usr/include/c++/4.7/bits/locale_facets_nonio.tcc: In member function â_InIter std::time_get<_CharT, _InIter>::_M_extract_name(std::time_get<_CharT, _InIter>::iter_type, std::time_get<_CharT, _InIter>::iter_type, int&, const _CharT**, std::size_t, std::ios_base&, std::ios_base::iostate&) constâ:
/usr/include/c++/4.7/bits/locale_facets_nonio.tcc:918:22: error: expected unqualified-id before â(â token
In file included from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/test/TestProductExample.cpp:15:0:
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h: At global scope:
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:69:13: warning: âvoid next_state()â declared âstaticâ but never defined [-Wunused-function]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:64:22: warning: ârandgen::stateâ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:65:12: warning: ârandgen::leftâ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:66:12: warning: ârandgen::initfâ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:67:23: warning: ârandgen::nextâ defined but not used [-Wunused-variable]
make[2]: *** [CMakeFiles/TestProductExample.dir/test/TestProductExample.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestProductExample.dir/all] Error 2
make: *** [all] Error 2
Boost library header files were included in PATH AND SYMBOLS but building the program generates an error message:
10:27:13 **** Incremental Build of configuration gcc-debug for project DB8 ****
make MODE=debug CONFIGNAME=gcc-debug all
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `mkdir -p "out/gcc-debug/" && echo "-g -Wall - I/usr/include -fno-stack-protector -DXMLPARSER=libxml -DWITH_PARSIM - DWITH_NETBUILDER -I"C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include" -I"C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn" -IC:/local/boost_1_59_0/boost -I. - IC:/Users/LuisH.Forchesatto/Downloads/omnetpp-4.6/include" >out/gcc-debug//.last- copts'
defaultSensor.cc
In file included from C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/connection.h:33:0,
from C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/mysql_connection.h:30,
from dbWriteWin.h:6,
from defaultSensor.cc:6:
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/warning.h:40:0: warning: ignoring #pragma warning [- Wunknown-pragmas]
#pragma warning (disable : 4290)
^
In file included from C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/variant.h:38:0,
from C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/connection.h:35,
from C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/mysql_connection.h:30,
from dbWriteWin.h:6,
from defaultSensor.cc:6:
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/exception.h:48:0: warning: ignoring #pragma warning [- Wunknown-pragmas]
#pragma warning (disable : 4290)
^
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/exception.h:52:0: warning: ignoring #pragma warning [- Wunknown-pragmas]
#pragma warning(push)
^
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/exception.h:53:0: warning: ignoring #pragma warning [- Wunknown-pragmas]
#pragma warning(disable: 4275)
^
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/cppconn/exception.h:58:0: warning: ignoring #pragma warning [- Wunknown-pragmas]
#pragma warning(pop)
^
In file included from dbWriteWin.h:6:0,
from defaultSensor.cc:6:
C:/Program Files (x86)/MySQL/MySQL Connector C++ 1.1.6/include/mysql_connection.h:31:32: fatal error: boost/shared_ptr.hpp: No such file or directory
#include <boost/shared_ptr.hpp>
^
compilation terminated.
make: *** [out/gcc-debug//defaultSensor.o] Error 1
Makefile:94: recipe for target 'out/gcc-debug//defaultSensor.o' failed
10:27:14 Build Finished (took 1s.183ms)
The library is installed in the system, the folder/file exists in the computer and it's path is correct. What can be causing this error?
Contents of path and symbols:
https://dl.dropboxusercontent.com/u/85576999/paths%20and%20symbols.png
Contents of the boost library folder:
https://dl.dropboxusercontent.com/u/85576999/boost%20folder.png
Do not use spaces in paths. I suggest moving (or reinstalling) MySQL Connector libraries to the folder with simple name without spaces, for example: c:\mysqlconnector.
Check whether the path to boost is set for C++ language too - on the Path and Symbols screen there is Assembly language focused.
Take into account these cluses provided by Rudi.
I'm compiling a C++ project that depends on google-sparsehash.
So I did install sparse through brew install google-sparsehash --cc=gcc-4.2 command.
But, when I finally compile my project I got fatal error: 'tr1/functional' file not found. I'd like to solve this problem, could you help me?
The output of the compiler is showed bellow:
c++ -- cb/allBalances.cpp
c++ -- cb/allAddresses.cpp
c++ -- callback.cpp
c++ -- cb/closure.cpp
c++ -- cb/dumpTX.cpp
c++ -- parser.cpp
c++ -- cb/pristine.cpp
c++ -- cb/rewards.cpp
clang: clang: clangclang: : clangclang: : clangclang: : warning: warning: warning: warning: warning: warning: warning: warning: argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'argument unused during compilation: '-fno-check-new'
In file included from cb/rewards.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
In file included from cb/pristine.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
In file included from cb/closure.cpp:4:
In file included from ./util.h:103:
In file included from /usr/local/include/google/dense_hash_map:34:
/usr/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
#include HASH_FUN_H // for hash<>#include HASH_FUN_H // for hash<>
^
When I type c++ -v I get:
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
Thank you.