Cooja hello-world-example.csc simulator in instantcontiki 3.0 is giving comiplation error: attempt to use poisoned "SPMCR" in boot.h - contiki

Inside instantcontiki3.0 ubuntu, started cooja simulator using command to start cooja simulator.
ant run
from folder /home/user/contiki/tools/cooja
Below error is seen when hellow world simulation is started from cooja simulator using following steps.
"File->Open simulation->2 cooja_helloworld.csc"->Select hello-world-example.csc->Open
In file included from ../../cpu/avr/dev/flash.c:4:0:
/usr/lib/avr/include/avr/boot.h:128:16: error: attempt to use poisoned "SPMCR"
#elif defined (SPMCR)
^
make: *** [obj_micaz/flash.o] Error 1
Below code is broken in instantcontiki3.0
/* Check for SPM Control Register in processor. */
#if defined (SPMCSR)
# define __SPM_REG SPMCSR
#elif defined (SPMCR)
# define __SPM_REG SPMCR
#else
# error AVR processor does not provide bootloader support!
#endif

Change below code
/* Check for SPM Control Register in processor. */
#if defined (SPMCSR)
# define __SPM_REG SPMCSR
#elif defined (SPMCR)
# define __SPM_REG SPMCR
#else
# error AVR processor does not provide bootloader support!
#endif
to
/* Check for SPM Control Register in processor. */
#if defined (SPMCSR)
# define __SPM_REG SPMCSR
//#elif defined (SPMCR)
//# define __SPM_REG SPMCR
#else
//# error AVR processor does not provide bootloader support!
# if defined (SPMCR)
# define __SPM_REG SPMCR
# else
# error AVR processor does not provide bootloader support!
# endif
#endif
inside /usr/lib/avr/include/avr/boot.h

Related

PCL can't find header file

/home/ubuntu/emvs_ws/src/rpg_emvs/mapper_emvs/src/realtime.cpp:25:62: fatal error: pcl/registration/impl/incremental_registration.hpp: No such file or directory
compilation terminated.
rpg_emvs/mapper_emvs/CMakeFiles/realtime_emvs.dir/build.make:62: recipe for target 'rpg_emvs/mapper_emvs/CMakeFiles/realtime_emvs.dir/src/realtime.cpp.o' failed
make[2]: *** [rpg_emvs/mapper_emvs/CMakeFiles/realtime_emvs.dir/src/realtime.cpp.o] Error 1
I'm getting this error after catkin_make
Theses are the includes in realtime.cpp
#include <pcl/registration/incremental_registration.h>
#include <pcl/registration/icp.h>
CMakeLists.txt file
project(mapper_emvs)
cmake_minimum_required(VERSION 2.8.3)
find_package(catkin_simple REQUIRED)
catkin_simple(ALL_DEPS_REQUIRED)
set(CMAKE_BUILD_TYPE RelWithDebInfo) # Release, RelWithDebInfo
set(CMAKE_CXX_FLAGS "-O3 -fopenmp -std=c++11 ${CMAKE_CXX_FLAGS}")
## Generate dynamic reconfigure parameters in the 'cfg' folder
##generate_dynamic_reconfigure_options(
## cfg/EMVSCfg.cfg
##)
set(HEADERS
include/mapper_emvs/mapper_emvs.hpp
include/mapper_emvs/data_loading.hpp
include/mapper_emvs/depth_vector.hpp
include/mapper_emvs/trajectory.hpp
include/mapper_emvs/geometry_utils.hpp
include/mapper_emvs/median_filtering.hpp
)
set(SOURCES
src/mapper_emvs.cpp
src/data_loading.cpp
src/median_filtering.cpp
)
option(DEFINE_USE_INVERSE_DEPTH "Use linear spacing in inverse depth (if OFF, will use linear spacing in depth)" ON)
if(DEFINE_USE_INVERSE_DEPTH)
add_definitions(-DUSE_INVERSE_DEPTH)
endif(DEFINE_USE_INVERSE_DEPTH)
cs_add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
# Executables
################################################################################
cs_add_executable(run_emvs src/main.cpp)
target_link_libraries(run_emvs ${PROJECT_NAME})
cs_add_executable(realtime_emvs src/realtime.cpp)
add_dependencies(realtime_emvs ${PROJECT_NAME}_gencfg)
target_link_libraries(realtime_emvs ${PROJECT_NAME})
################################################################################
cs_install()
cs_export()
Note that I did Catkin_make not catkin build, I don;t know if this makes a difference.
I'm asked to add more details, so please ignore this line :)
You need to add PCL library in your CMakeLists.txt file as follows:
project(mapper_emvs)
cmake_minimum_required(VERSION 2.8.3)
find_package(catkin_simple REQUIRED)
# Adding PCL lib
find_package(PCL REQUIRED)
# Setting include, lib directories and definitions
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS} )
add_definitions(${PCL_DEFINITIONS} )
catkin_simple(ALL_DEPS_REQUIRED)
set(CMAKE_BUILD_TYPE RelWithDebInfo) # Release, RelWithDebInfo
set(CMAKE_CXX_FLAGS "-O3 -fopenmp -std=c++11 ${CMAKE_CXX_FLAGS}")
## Generate dynamic reconfigure parameters in the 'cfg' folder
##generate_dynamic_reconfigure_options(
## cfg/EMVSCfg.cfg
##)
set(HEADERS
include/mapper_emvs/mapper_emvs.hpp
include/mapper_emvs/data_loading.hpp
include/mapper_emvs/depth_vector.hpp
include/mapper_emvs/trajectory.hpp
include/mapper_emvs/geometry_utils.hpp
include/mapper_emvs/median_filtering.hpp
)
set(SOURCES
src/mapper_emvs.cpp
src/data_loading.cpp
src/median_filtering.cpp
)
option(DEFINE_USE_INVERSE_DEPTH "Use linear spacing in inverse depth (if OFF, will use linear spacing in depth)" ON)
if(DEFINE_USE_INVERSE_DEPTH)
add_definitions(-DUSE_INVERSE_DEPTH)
endif(DEFINE_USE_INVERSE_DEPTH)
cs_add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
# Executables
################################################################################
cs_add_executable(run_emvs src/main.cpp)
target_link_libraries(run_emvs ${PROJECT_NAME} ${PCL_LIBRARIES})
cs_add_executable(realtime_emvs src/realtime.cpp)
add_dependencies(realtime_emvs ${PROJECT_NAME}_gencfg)
target_link_libraries(realtime_emvs ${PROJECT_NAME} ${PCL_LIBRARIES})
################################################################################
cs_install()
cs_export()
Note: Hope you installed PCL lib. Besides,
I added ${PCL_LIBRARIES} into target_link_libraries. I hope it will work this way, if you are getting some errors, try adding ${PCL_LIBRARIES} into cs_add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${PCL_LIBRARIES}). Please let us know if get errors after applying these changes.

xCode project not locating c++ std libraries on macOS Catalina 10.15.5

I have an xCode Swift 5 project using Metal which has two targets, the main app, and a static library target which builds a third party C library. When I compile the project, error messages (see below) indicate that xCode is searching iPhone SDK for system C headers, which it doesn't find, and doesn't find them anywhere. How can I fix this? please :)
The static library target builds a third party C library, and has an Obj-c public h/m file (AGBGPUType.h, AGBGPUType.m).
This library header is referenced in a bridging header file (Common.h) in a Swift/Metal project.
All of the internal library header files and relevant source are included within the Swift/Metal project - this is not a workspace, it is a single project with two targets.
The scheme to build the app target is setup to compile the library first, then the app, the device I'm building with is an iPhone Xs Max running iOS 13.5.
I've set up the C library's public Obj-c (.h & .m) to log to the console and create a reference to a font library - which would mean it can access the third party C library code in a functional way.
The library obj-c file is:
#import "AGBGPUType.h"
#import "ft2build.h"
#include FT_FREETYPE_H
#include FT_STROKER_H
#implementation AGBGPUType
FT_Library _fontLibrary;
FT_Face _face;
FT_GlyphSlot _glyph;
FT_Stroker _stroker;
-(void) simple {
int giddy = 5000;
NSLog(#"From main library objc AGBGPUType.m %d", giddy);
if(FT_Init_FreeType(&_fontLibrary)) {
NSLog(#"Could not init Freetype library");
}
}
#end
and the bridging header file within the Swift/Metal application has:
#ifndef Common_h
#define Common_h
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#import <simd/simd.h>
#import "AGBGPUType/AGBGPUType.h"
...
#endif
The following errors are generated when the application is built:
CompileMetalFile /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal (in target 'IncuFlic' from project 'IncuFlic')
cd /Users/username/Documents/xCode/IncuFlic
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal -c -target air64-apple-ios13.5 -gline-tables-only -MO -I/Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Build/Products/Debug-iphoneos/include -F/Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Build/Products/Debug-iphoneos -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk -ffast-math -serialize-diagnostics /Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Build/Intermediates.noindex/IncuFlic.build/Debug-iphoneos/IncuFlic.build/Metal/Shaders.dia -o /Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Build/Intermediates.noindex/IncuFlic.build/Debug-iphoneos/IncuFlic.build/Metal/Shaders.air -index-store-path /Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Index/DataStore "" -MMD -MT dependencies -MF /Users/username/Library/Developer/Xcode/DerivedData/IncuFlic-fxtjxtzaumyrcuhiwrtiajlsnzak/Build/Intermediates.noindex/IncuFlic.build/Debug-iphoneos/IncuFlic.build/Metal/Shaders.dat /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal:35:
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Common.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
##error Unsupported architecture##
^
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal:35:
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Common.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
##error architecture not supported##
^
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal:35:
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Common.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/Toolchains/XcodeDefault.xctoolchain/usr/metal/ios/lib/clang/3902.67/include/metal/metal_types:48:25: note: 'uint64_t' declared here
typedef __UINT64_TYPE__ uint64_t;
^
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal:35:
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Common.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.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 /Users/username/Documents/xCode/IncuFlic/IncuFlic/Shaders.metal:35:
In file included from /Users/username/Documents/xCode/IncuFlic/IncuFlic/Common.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_types.h:80:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_pthread/_pthread_types.h:58:25: error: pointer type must have explicit address space qualifier
void (*__routine)(void *); // Routine to call
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_pthread/_pthread_types.h:59:7: error: pointer type must have explicit address space qualifier
void *__arg; // Argument to pass
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/usr/include/sys/_pthread/_pthread_types.h:60:38: error: pointer type must have explicit address space qualifier
struct __darwin_pthread_handler_rec *__next;
Additional Environment Details
My path
sudo nano /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
The currently active developer dir
xcode-select -p
/Applications/Xcode.app/Contents/Developer
The GCC compiler gcc -v
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.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
The C preprocessor cpp -v
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.4 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 556.6 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /usr/include -I/usr/local/include -internal-isystem
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include -internal-externc-isystem
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-objc-signed-char-bool-implicit-int-conversion -Wno-extra-semi-stmt -Wno-quoted-include-in-framework-header -fdebug-compilation-dir /Users/annstramer -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.15.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -traditional-cpp -o - -x c -
clang -cc1 version 11.0.3 (clang-1103.0.32.62) default target x86_64-apple-darwin19.5.0
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
include "..." search starts here:
include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
From reading several articles, including Broken c++ std libraries on macOS High Sierra 10.13 and How can I find all Clang versions installed on my Mac?, possibly xCode is not finding headers of C installation. The error messages indicate that xCode is looking for files in the iPhone13.5 sdk, but terminal commands seem to confirm a version of C isn't included with that sdk.
There exists a C installation in the xCode developer directory.
When the library is included as a prebuilt archive in an Obj-c project or a Swift project, the project compiles without errors, C headers are found, logs the message to the console and create the reference to the font library. Golden - but doesn't work at all from bridging header in Swift/Metal project. There are several structs in that bridging header which work perfectly in other areas of Swift/Metal code.
A (brute force) clean installation of xCode didn't solve the problem, nor did installing the command line tools, both of these after installing the recent Catalina upgrade over a relatively recent clean install of Catalina, and then just today installing a command line tools upgrade.
My questions:
Am I correct that xCode is not locating a C installation?
cpp -v finds xCode's C installation, why doesn't xCode during compile?
Please, what is the correct professional way to solve this problem?
Thanks in advance for your insights.
Here is an excellent explanation as an overview for this issue, from Cecelia Humlelu.
https://www.youtube.com/watch?v=NvURClY2Xzk
I found this explanation of how to integrate the C library exceedingly direct also, and contemporary to xCode 11: https://www.youtube.com/watch?v=WQI02KR9kQw
I was convoluting the integration of the C library into the Swift project by building the C library within an ObjC library target, and then using ObjC to access the library.
Since Swift can directly consume C, I deleted the Obj-C library target, built the C library from the command line, and dropped the archive and headers into the project (see 2nd video link). The first 6 minutes of Cecelia's video are key to understanding why these changes worked, and the C/Swift segment that starts at 6:45 clearly outlines what I followed. To the letter.
In this project, the bridging header is imported in the metal shader. I was importing the C library within the bridging header, using an Obj-C header file. Deleting this Obj-C header, and writing C functions appeared to work at first.
However, when it came down to using the core functionality of the library, there was another problem. This library involves processing strings, and to pass a string from a Swift function call into a C function call, pointer parameters had to be added to the C function calls that use the library code. Address space qualifiers are required for running code on the GPU. Since the C functions were being imported in a bridging header through Metal, the compiler requires the code to designate address space identifiers. The problem is that C does not have a construct for designating the address space of the pointer parameters, so importing these function declarations in the bridging header was not possible. Please note: there are some C declarations that would not require address space qualifiers, the discussion is out of scope for this question.
There is only one bridging header allowed per target in an xCode project, but there is another way to import header files. I created a modulemap for the library header file, and added it to the Import Paths setting of Swift Compiler Search Paths in the project build settings. Because this library uses complex macros to expose functionality, a C or Obj-C wrapper is still needed to use the library from Swift, but the library is fully integrated and accessible from CPU code.
In the working solution, Swift recognizes the header files in the modulemap as globally defined, so they can be called from any Swift file in the project, the library header files are no longer referenced in the target's bridging header.
I followed the video to the letter in it's guidance about creating a modulemap for the C library.
Here's the Obj-C source file declaration:
#import <LibraryWrapperCode.h>
#import <MetalKit/MetalKit.h>
#include "ft2build.h"
#include FT_FREETYPE_H
#implementation LibraryWrapperCode {
FT_Library _fontLibrary;
FT_Face _face;
FT_GlyphSlot _glyph;
}
The modulemap:
module GPUTextCWrapper {
header "../GPUText/libraryWrapperCode.h"
export *
}
The C library is imported from any Swift file:
import GPUTextCWrapper
It is still somewhat unclear to me what I was doing that generated the error messages documented in this question, but I think I was importing the library in such a way that the compiler found it twice, and the second time, tried to recompile the library. I will update this answer again if I find a more direct explanation.

Undefined symbol using emcmake (emscripten and opencv)

I'm trying to build a minimalist project using OpenCV in the browser.
I've compiled OpenCV on my computer.
Here is the C++ code (josef.cpp):
#include <iostrem>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
int main(int argc, char **argv)
{
printf("Hello here\n");
cv::Mat m;
std::cout << m;
}
Here is the CMakeLists.txt :
cmake_minimum_required(VERSION 2.8)
project( josef )
# Give here the directory in which we have
# the file OpenCVConfig.cmake
set(OpenCV_DIR "/usr/local/lib/cmake/opencv4")
find_package( OpenCV REQUIRED )
add_executable( josef josef.cpp )
target_link_libraries( josef ${OpenCV_LIBS} )
Compiling with
cmake .
make
works perfectly well and provides an executable which produces the expected result:
Hello here
[]
My problem arises when trying with emscripten.
emcmake cmake .
produces lot of warnings like that one:
CMake Warning (dev) at /usr/local/lib/cmake/opencv4/OpenCVModules.cmake:393 (add_library):
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
Call Stack (most recent call first):
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:126 (include)
CMakeLists.txt:7 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
Then
emmake make
fails on undefined symbols:
error: undefined symbol: _ZN2cv3Mat10deallocateEv
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
My question is : what do I wrong ? How to tell emscripten where are the famous missing symbols (these are the file .so if I understood correctly) ?
This is partially a hack solution.
In the file /usr/local/lib/cmake/opencv4/OpenCVModules.cmake, change every instances of "SHARED" by "STATIC".
In your cmake file, add the line
file( GLOB opencv_js "/path/to/opencvjs/opencv/build_js/lib/*.a")
This part supposes that you compiled opencv by hand.
then refer to my answer to my next question. (in short: use a canvas, do not use cv::imdecode.)

'iterator' file not found when compiling bar for iOS

I was using Xcode 11 to compile zbar for my iOS Device.
However it gives me this error:'iterator' file not found
Some code:
#ifndef _ZBAR_IMAGE_H_
#define _ZBAR_IMAGE_H_
/// #file
/// Image C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Image.h"
#endif
#include <assert.h>
#include <iterator>
#include "Symbol.h"
#include "Exception.h"
I have tried to clean and rebuild and this didn't seem to work.
Environment:
Mac OS Catalina 10.15 Beta (19A558d)
Xcode 11.0(11A420a)
C11
<iterator> is a c++ reference, please refer to here.
so,
a. Renaming the image.c to image.cpp
or
b. Compile with g++, NOT gcc
would be helpful.

'pod lib lint' conflict between 'route.h' and <net/route.h>

I'm trying to run pod lib lint on a Cocoa Framework swift project and it returns the following error:
- ERROR | [iOS] xcodebuild: /MyProject/route.h:164:8: error: redefinition of 'rt_msghdr2'
- NOTE | [iOS] xcodebuild: /Applications/Xcode.app/Contents/Developer/Platforms
/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk
/usr/include/net/route.h:164:8:
note: previous definition is here
I have an Objective-C class (NetworkUtil.h - NetworkUtil.m) with the following import structure.
#if TARGET_IPHONE_SIMULATOR
#include <net/route.h>
#else
#include "route.h"
#endif
This, because route.h file only exist in the iOS Simulator SDK, but not in the actual iOS SDK (https://stackoverflow.com/a/23411469/5973853). I check whether it is an iPhone simulator, so the original < net/route.h > will be imported, or it runs on an actual iPhone, in that case it gets my manually copied 'route.h'.
Xcode manages to build and run the whole project correctly, but xcodebuild used by pod lib lint doesn't. For some reason, it imports both < net/route.h > and 'route.h' without considering the #if_TARGET_IPHONE_SIMULATOR validation and that makes the conflict due to "redefinition of several functions".
Is there any solution or workaround to this conflict?

Resources