Compilation headers for 64-bit ARM64 Raspberry Pi for Yate? - c

When I try to compile Nuand's Yate software on 64-bit (ARM64) Ubuntu 21.04 on a Raspberry Pi 4, I get architecture support headers errors:
~/software/bts/yate$ make
make -C ./engine all
make[1]: Entering directory '/home/parallels/software/bts/yate/engine'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/parallels/software/bts/yate/engine'
make -C ./modules all
make[1]: Entering directory '/home/parallels/software/bts/yate/modules'
make -C ../libs/miniwebrtc
make[2]: Entering directory '/home/parallels/software/bts/yate/libs/miniwebrtc'
g++ -Wall -I. -I./audio/common/processing -I./audio/common/vad -I./audio/processing/aec -I./audio/processing/aecm -I./audio/processing/agc -I./audio/processing/ns -I./audio/processing/utility -I./system_wrappers -O2 -Wno-overloaded-virtual -fno-exceptions -fPIC -DHAVE_GCC_FORMAT_CHECK -DHAVE_BLOCK_RETURN -DWEBRTC_NS_FLOAT=true -c -o audio/common/resampler/resampler.o audio/common/resampler/resampler.cc
In file included from ./audio/common/processing/signal_processing_library.h:22,
from audio/common/resampler/resampler.cc:19:
./typedefs.h:104:2: error: #error Please add support for your architecture in typedefs.h
104 | #error Please add support for your architecture in typedefs.h
| ^~~~~
make[2]: *** [Makefile:263: audio/common/resampler/resampler.o] Error 1
make[2]: Leaving directory '/home/parallels/software/bts/yate/libs/miniwebrtc'
make[1]: *** [Makefile:448: ../libs/miniwebrtc/libminiwebrtc.a] Error 2
make[1]: Leaving directory '/home/parallels/software/bts/yate/modules'
make: *** [Makefile:186: modules] Error 2
When I check the typedefs.h header, I see arm64 support is not added yet:
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
// This file contains platform-specific typedefs and defines.
#ifndef WEBRTC_TYPEDEFS_H_
#define WEBRTC_TYPEDEFS_H_
// Reserved words definitions
// TODO(andrew): Look at removing these.
#define WEBRTC_EXTERN extern
#define G_CONST const
#define WEBRTC_INLINE extern __inline
// Define WebRTC preprocessor identifiers based on the current build platform.
// TODO(andrew): Clean these up. We can probably remove everything in this
// block.
// - TARGET_MAC_INTEL and TARGET_MAC aren't used anywhere.
// - In the few places where TARGET_PC is used, it should be replaced by
// something more specific.
// - Do we really support PowerPC? Probably not. Remove WEBRTC_MAC_INTEL
// from build/common.gypi as well.
#if defined(WIN32)
// Windows & Windows Mobile.
#if !defined(WEBRTC_TARGET_PC)
#define WEBRTC_TARGET_PC
#endif
#elif defined(__APPLE__)
// Mac OS X.
#if defined(__LITTLE_ENDIAN__ )
#if !defined(WEBRTC_TARGET_MAC_INTEL)
#define WEBRTC_TARGET_MAC_INTEL
#endif
#else
#if !defined(WEBRTC_TARGET_MAC)
#define WEBRTC_TARGET_MAC
#endif
#endif
#else
// Linux etc.
#if !defined(WEBRTC_TARGET_PC)
#define WEBRTC_TARGET_PC
#endif
#endif
// Derived from Chromium's build/build_config.h
// Processor architecture detection. For more info on what's defined, see:
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
// http://www.agner.org/optimize/calling_conventions.pdf
// or with gcc, run: "echo | gcc -E -dM -"
// TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN?
#if defined(_M_X64) || defined(__x86_64__)
#define WEBRTC_ARCH_X86_FAMILY
#define WEBRTC_ARCH_X86_64
#define WEBRTC_ARCH_64_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(_M_IX86) || defined(__i386__)
#define WEBRTC_ARCH_X86_FAMILY
#define WEBRTC_ARCH_X86
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(__ARMEL__)
// TODO(andrew): We'd prefer to control platform defines here, but this is
// currently provided by the Android makefiles. Commented to avoid duplicate
// definition warnings.
//#define WEBRTC_ARCH_ARM
// TODO(andrew): Chromium uses the following two defines. Should we switch?
//#define WEBRTC_ARCH_ARM_FAMILY
//#define WEBRTC_ARCH_ARMEL
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(__mips__)
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_BIG_ENDIAN
#elif defined(__powerpc64__)
#define WEBRTC_ARCH_PPC64 1
#define WEBRTC_ARCH_64_BITS
#ifdef __LITTLE_ENDIAN__
#define WEBRTC_ARCH_LITTLE_ENDIAN
#define WEBRTC_LITTLE_ENDIAN
#else
#define WEBRTC_ARCH_BIG_ENDIAN
#define WEBRTC_BIG_ENDIAN
#endif
#elif defined(__powerpc__)
#define WEBRTC_ARCH_PPC 1
#define WEBRTC_ARCH_32_BITS
#ifdef __LITTLE_ENDIAN__
#define WEBRTC_ARCH_LITTLE_ENDIAN
#define WEBRTC_LITTLE_ENDIAN
#else
#define WEBRTC_ARCH_BIG_ENDIAN
#define WEBRTC_BIG_ENDIAN
#endif
#else
#error Please add support for your architecture in typedefs.h
#endif
#if defined(__SSE2__) || defined(_MSC_VER)
#define WEBRTC_USE_SSE2
#endif
#if defined(WEBRTC_TARGET_PC)
#if !defined(_MSC_VER)
#include <stdint.h>
#else
// Define C99 equivalent types.
// Since MSVC doesn't include these headers, we have to write our own
// version to provide a compatibility layer between MSVC and the WebRTC
// headers.
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#endif
#if defined(WIN32)
typedef __int64 WebRtc_Word64;
typedef unsigned __int64 WebRtc_UWord64;
#else
typedef int64_t WebRtc_Word64;
typedef uint64_t WebRtc_UWord64;
#endif
typedef int32_t WebRtc_Word32;
typedef uint32_t WebRtc_UWord32;
typedef int16_t WebRtc_Word16;
typedef uint16_t WebRtc_UWord16;
typedef char WebRtc_Word8;
typedef uint8_t WebRtc_UWord8;
// Define endian for the platform
#define WEBRTC_LITTLE_ENDIAN
#elif defined(WEBRTC_TARGET_MAC_INTEL)
#include <stdint.h>
typedef int64_t WebRtc_Word64;
typedef uint64_t WebRtc_UWord64;
typedef int32_t WebRtc_Word32;
typedef uint32_t WebRtc_UWord32;
typedef int16_t WebRtc_Word16;
typedef char WebRtc_Word8;
typedef uint16_t WebRtc_UWord16;
typedef uint8_t WebRtc_UWord8;
// Define endian for the platform
#define WEBRTC_LITTLE_ENDIAN
#else
#error "No platform defined for WebRTC type definitions (typedefs.h)"
#endif
#endif // WEBRTC_TYPEDEFS_H_
So I reported this error to manufacturer Nuand, but they were not responding quickly on how to resolve these issues. So if I would add support for the raspberry pi manually, What's the correct way to add support for ARM64 without resulting into errors after compilation?
I tried:
#elif defined(__aarch64__)
#define WEBRTC_ARCH_64_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
But it didn't result into a working Yate binary:
make[1]: Leaving directory '/home/yate/yate-rc-2/yate/conf.d'
make: *** [Makefile:259: install-api] Error 1

Related

Is there a way to define macro for pins in AVR gcc so i can access those as variables?

I'm trying to write definitions for AVR C code so that i can access pins by simmple macro like
STATUS_LED_OUT =1;
in GENET_HW_DEF.h file, included to main C file. You can reproduce this bug by including this file into any C project.
I'm using avr studio 6.2 and 7 - both give the same result. I cannot compile getting werid macro unfold message like below. (CPU ATMega1284p)
D:\_SVN\Compass\AVR\Compass_IO_proto\Compass IO_proto\GENET_HW_DEF.h(19,49): error: expected ')' before '&' token
#define REGISTER_BIT(rg,bt) ((volatile _io_reg*)&rg)->bit##bt
^
D:\_SVN\Compass\AVR\Compass_IO_proto\Compass IO_proto\GENET_HW_DEF.h(42,25): info: in expansion of macro 'REGISTER_BIT'
#define STATUS_LED_OUT REGISTER_BIT(PORTB,7)
^
D:\_SVN\Compass\AVR\Compass_IO_proto\Compass IO_proto\GENET_HW_DEF.h(46,2): info: in expansion of macro 'STATUS_LED_OUT'
STATUS_LED_OUT=1;
^
Interesting enough, copied to fresh project with just only one or two declarations compiles fine, until one makes any changes in the declarations - like adding another macro reference. Then it becomes stuck again.
Also - if i comment all macro usages like
STATUS_LED_DIR=1;
STATUS_LED_OUT=1;
then I'm able to compile project and then after uncommenting usage lines it still compiles fine.. untill clean is executed. I'm probably messing with macro quirks but I have no idea where.
typedef struct
{
unsigned int bit0:1;
unsigned int bit1:1;
unsigned int bit2:1;
unsigned int bit3:1;
unsigned int bit4:1;
unsigned int bit5:1;
unsigned int bit6:1;
unsigned int bit7:1;
} _io_reg;
#define REGISTER_BIT(rg,bt) ((volatile _io_reg*)&rg)->bit##bt
#ifndef GENET_HW_DEF
#define GENET_HW_DEF
// define functionalities and flags - comment/uncomment apropriate lines
#define GENET_USART_0 256
#define GENET_USART_1 256
#define F_CPU 20000000UL
#define STATUS_LED 7
#define ERROR_LED 4
#define ADC_GLOBAL_ENABLE A
#define ADC_CHANNEL_0 0
#define ADC_CHANNEL_1 4
#define ADC_CHANNEL_2 2
#define ADC_CHANNEL_3 3
#define ADC_CHANNEL_4 1
#define ADC_CHANNEL_5 5
#define ADC_CHANNEL_6 6
#define ADC_CHANNEL_7 7
// actual definitions and initialization
#ifdef STATUS_LED
#define STATUS_LED_OUT REGISTER_BIT(PORTB,STATUS_LED)
#define STATUS_LED_DIR REGISTER_BIT(DDRB,STATUS_LED)
#define STATUS_LED_PIN REGISTER_BIT(PINB,STATUS_LED)
STATUS_LED_DIR=1;
STATUS_LED_OUT=1;
#endif
#ifdef ERROR_LED
#define ERROR_LED_OUT REGISTER_BIT(PORTC,ERROR_LED)
#define ERROR_LED_DIR REGISTER_BIT(DDRC,ERROR_LED)
ERROR_LED_DIR=1;
ERROR_LED_OUT=1;
#endif
#ifdef GENET_USART_0
#define USART0_ENABLED
#define UART_RX0_BUFFER_SIZE GENET_USART_0
#define UART_TX0_BUFFER_SIZE GENET_USART_0
#endif
#ifdef GENET_USART_1
#define USART1_ENABLED
#define UART_RX1_BUFFER_SIZE GENET_USART_1
#define UART_TX1_BUFFER_SIZE GENET_USART_1
#endif
#endif
I reproduced your problem.
You cannot call STATUS_LED_DIR=1; outside code execution flow. This must be inside a function (for example main()).
Now you will end with other compilation errors but this was the main mistake.
Second correction, you need 2 level for concatenation
#define CONCAT(bt) bit##bt
#define REGISTER_BIT(rg,bt) ((volatile _io_reg*)&rg)->CONCAT(bt)

undeclared here (not in a function) in C

im new with c language, but i try to unerstand this quark hashing algorithm that was written in c language, and i found an error while im compiling the source code, from what i understand the WIDTH it already declared, but why is it still error ?
this is the source code
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
/* uncomment to printf execution traces */
// #define DEBUG
#if defined(UQUARK)
#define CAPACITY 16
#define RATE 1
#define WIDTH 17
#elif defined(DQUARK)
#define CAPACITY 20
#define RATE 2
#define WIDTH 22
#endif
#define DIGEST WIDTH
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint8_t u8;
typedef struct {
int pos; /* number of bytes read into x from current block */
// u32 x[ WIDTH*8 ]; /* one bit stored in each word */
u32 x[ WIDTH*8 ]; /* one bit stored in each word */
} hashState;
#if defined(UQUARK)
/* 17 bytes */
u8 iv[] = {0xd8,0xda,0xca,0x44,0x41,0x4a,0x09,0x97,
0x19,0xc8,0x0a,0xa3,0xaf,0x06,0x56,0x44,0xdb};
and its showing this error
quark.c:36:10: error : 'WIDTH' undeclared here (not in a function)
u32 x[WIDTH*8];
I guess for some reason neither UQUARK nor DQUARK are defined.
Add this:
#if defined(UQUARK) && defined(DQUARK)
#error both UQUARK and DQUARK are defined
#endif
#if !defined(UQUARK) && !defined(dQUARK)
#error Neither UQUARK nor DQUARK are defined
#endif
just before following line:
#if defined(UQUARK)
Then the compilation will abort if either both UQUARK and DQUARK are defined (which probably makes no sense) or if neither UQUARK nor DQUARK are defined (which probably happens in your case).
Now the question is: who defines UQUARK and/or DQUARK? Only you can tell.

Getting embedded PACKED_STRUCT definition to compile under g++

I'm working on a smart meter project, ARM, keil compiler. I want to compile some of the more complex logic under g++ to run regression tests. I'm having a problem with some include files defining the interface to WMBus stack we purchased.
PACKED_STRUCT( typedef struct S_WMBUS_ADDR_T
{
/*! Manufacturer ID */
uint8_t pc_manufr[WMBUS_ADDR_MANUFR_LEN];
/*! Ident number */
uint8_t pc_ident[WMBUS_ADDR_IDENT_LEN];
/*! Version */
uint8_t c_version;
/*! Type */
uint8_t c_type;
}, s_wmbus_addr_t);
PACKED_STRUCT is defined in a compiler sensitive include file:
#elif defined (__GNUC__)
#define PACKED_STRUCT(__declaration__, __name__) \
__declaration__ __attribute__ ((__packed__)) __name__
...
#elif defined(__arm__)
#ifdef __ARMCC_VERSION
#define PACKED_STRUCT(__declaration__, __name__) \
__packed __declaration__ __name__
And I always get the following error messages:
error: types may not be defined in parameter types
error: typedef declaration invalid in parameter declaration
I can so no way around this other than by editing the include file to remove the PACKED_STRUCT. Obviously I won't edit the files directly, I'll copy them, edit them, and use the -I directive to make it find my modified files under G++
The error message seems to be saying you cannot declare a type as an argument to a macro?
Note even if I redeclare:
#define PACKED_STRUCT(__declaration__, __name__) \
__declaration__ __name__
I am using the -std=c++11 flag to g++ but removing this flag solves nothing, but makes a system include fail
Is there any way I can define PACKED_STRUCT to make the unmodified code compile under g++?
#LP You are right, though I'm not sure why right now. This code compiles:
I must have a wrong include file slipping through somehow.
typedef unsigned char uint8_t;
#define WMBUS_ADDR_MANUFR_LEN 4
#define WMBUS_ADDR_IDENT_LEN 4
#define PACKED_STRUCT(__declaration__, __name__) \
__declaration__ __attribute__ ((__packed__)) __name__
PACKED_STRUCT( typedef struct S_WMBUS_ADDR_T
{
/*! Manufacturer ID */
uint8_t pc_manufr[WMBUS_ADDR_MANUFR_LEN];
/*! Ident number */
uint8_t pc_ident[WMBUS_ADDR_IDENT_LEN];
/*! Version */
uint8_t c_version;
/*! Type */
uint8_t c_type;
}, s_wmbus_addr_t);
s_wmbus_addr_t hello;

Error compiling metismex in matlab r2013

I have downloaded and succesfully compiled metis 5.0.2 in a win7 x64 pc
and trying to compile metismex.
I compiled metis with Visual Studio 11 (2012) and using the same compiler from within matlab.
After a lot of experimentation with a ton of errors (mainly owed to paths issues from within the libraries) I have reached a point where I dont know how to proceed, since my knowledge on c and c++ is pretty basic.
So, here's the error :
../GKlib/mat_libs/.\stddef.h(16) : error C2054: expected '(' to follow '_SIZE_TYPE__'
../GKlib/mat_libs/.\stddef.h(19) : error C2085: '_WCHAR_TYPE__' : not in formal parameter list
I found out about the inline functions etc, but since the error is within a library and dont exactly know what I should be doing, here I am. So, the error code is produced here :
typedef __SIZE_TYPE__ size_t;
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
#endif
any suggestions on what I should do without messing it up?
(in case I comment out wchar type, I also have the same error on prtdiff_type)
Thanks in advance
P.S: In case it is needed, here's the whole sttdef.h
/* Copyright 2012 The MathWorks, Inc. */
#ifndef _STDDEF_H
#define _STDDEF_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
# define NULL (0)
#else
# define NULL ((void *)0)
#endif
typedef __SIZE_TYPE__ size_t;
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
#endif
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#if (! defined(__cplusplus)) || (! defined(PST_GNU))
# define offsetof(type, field) ((size_t) &((type *)0)->field)
#else
# define offsetof(type, field) \
(__offsetof__(reinterpret_cast<size_t> \
(&reinterpret_cast<const volatile char &> \
(static_cast<type *>(0)->field))))
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _STDDEF_H *
/
Here is a walk-through of what I did. I'm running R2014a with VS2013 on Win8.1 x64.
1) First we compile metis:
Download and extract metis-5.1.0 to some location, say C:\metis-5.1.0
Edit C:\metis-5.1.0\include\metis.h and set #define IDXTYPEWIDTH 64 (for x64 architecture)
Next we generate Visual Studio projects using CMake:
> cd C:\metis-5.1.0
> vsgen -G "Visual Studio 12 2013 Win64"
Before we build the solution, we need to fix a few things first. Some header files are unnecessarily redefining rint function for MSVC (metisbin.h, metislib.h, and gk_arch.h). Remove such lines:
#ifdef __MSC__ /* MSC does not have rint() function */
#define rint(x) ((int)((x)+0.5))
/* MSC does not have INFINITY defined */
#ifndef INFINITY
#define INFINITY FLT_MAX
#endif
#endif
Also in GKlib\gk_externs.h replace all occurrences of __thread with __declspec(thread)
Next open the solution file C:\metis-5.1.0\build\windows\METIS.sln in Visual Stduio, and build ALL_BUILD target (make sure "x64" in "Release" mode is selected).
We are mainly interested in the metis project. Its result should be stored in C:\metis-5.1.0\build\windows\libmetis\Release\metis.lib (a static library).
2) Next we build the MEX-function:
Download metismex and extract it to a folder inside the previous location (C:\metis-5.1.0\metismex-master)
Again we need to fix a few things: first rename metismex.c to metismex.cpp (the C++ compiler is much better than the C compiler in Visual Studio!). Next edit this file and replace: #include <strings.h> with #include <string.h>, and add the following code immediately after it:
#if defined(_WIN32) || defined(_WIN64)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
Finally start MATLAB, and run the following command to compile the MEX-file:
>> cd('C:\metis-5.1.0\metismex-master')
>> mex -O -largeArrayDims -DWIN32 -DMSC -DUSE_GKREGEX -I../GKlib -I../include -I../libmetis metismex.cpp ../build/windows/libmetis/Release/metis.lib
You should now have the final metismex.mexw64
I should say that I know nothing about the library, so I cannot guarantee it gives correct results after all the above modifications. I'm just showing how to get it to compile. The code was written with Linux/OSX in mind, and relies on many POSIX features not intended for Windows. Also the whole 32 vs. 64 bit is a bit messy...

stddef.h: error: duplicate 'unsigned'

I'm compiling grep on the 64-bit GCC compiler for Windows 7 x64 SUA/Interix.
It chokes on the marked line in stddef.h:
#ifndef _SIZE_T_DEFINED
#if defined (lp64) || defined(_WIN64)
#ifdef lp64
typedef unsigned long size_t; // <------ error
#else /* lp64 */
typedef unsigned __int64 size_t;
#endif /* lp64 */
#else /* (defined(lp64) || defined(_WIN64)) */
typedef unsigned int size_t;
#endif /* (defined(lp64) || defined(_WIN64)) */
#define _SIZE_T_DEFINED
#define _SIZE_T
#endif /* _SIZE_T_DEFINED */
The output for make is:
make all-recursive
Making all in intl
gcc -c -DLOCALEDIR=\"/usr/local/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/local/share/locale\" -DLIBDIR=\"/usr/local/lib\" -DIN_LIBINTL -DHAVE_CONFIG_H -I.. -I. -I../../intl -D_ALL_SOURCE -D_REENTRANT -I/usr/local/include -I/usr/local/include -D_ALL_SOURCE -D_REENTRANT ../../intl/intl-compat.c
In file included from ../../intl/gettextP.h:23:0,
from ../../intl/intl-compat.c:25:
/usr/include/stddef.h:50:23: error: duplicate 'unsigned'
*** Error code 1
Stop in /tmp/grep-2.5.4-src/build/intl.
*** Error code 1
Stop in /tmp/grep-2.5.4-src/build (line 329 of Makefile).
*** Error code 1
Stop in /tmp/grep-2.5.4-src/build (line 244 of Makefile).
I don't understand what the cause is... it's already confusing that long is being used as though it's 64-bit in GCC, but the error is even more confusing! Ideas?
Somewhere in your code, somone probably did:
#define size_t unsigned long
Or something along those lines, without having defined _SIZE_T_DEFINED when they did it. Then their code #includes stddef.h via the path listed in your error message. That makes your error line look like:
typedef unsigned long unsigned long;
To the compiler, which is not going to work!

Resources