Received error:
libNCPH.h:39:15: fatal error: paillier.h: No such file or directory
39 | #include <paillier.h>
In libNCPH.h, it is also in this way:
extern "C" {
#include <gmp.h>
#include <paillier.h>
#include "tcp.h"}
Related
The Visual Studio 2019 shows E0020: "Sleep() is undefined" and C3861 'sleep':identifier not found.
I use "windows.h" but it doesn't work.
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <windows.h>
#include <dos.h>
#pragma comment(lib, "pthreadVC2.lib")
using namespace std;
..........
int main() {
pthread_t tid0;
pthread_t tid1;
pthread_create(&tid0, NULL, workerThreadFunc, (void*)&tid0);
pthread_create(&tid1, NULL, workerThreadFunc2, (void*)&tid1);
sleep(1); // E0020 identifier "sleep" is undefined**
THREADS_CREATED = 1;
pthread_exit(NULL);
return 0;
}
the "sleep(1)" should like this "Sleep(1)". The letter "s" should be capitalized.
I am working on two Beaglebone Black with Xenomai and RTnet. I have two c-files for a roundtrip ethernet frame between the BBB's. When I try to compile the first c-file there occur some errors:
undefined reference to 'rt_task_self'
rt_task_self is a function in my c-file and is declared in my headerfile "task.h". So in my opinion "undefined" means that it is just not defined in any cpp-file "task.cpp" for the headerfile "task.h".
But I am a little bit confused: How do I tell my program that my headerfile "task.h" is defined in my other file "task.cpp" or "task.o" or...
I have many header files in my C-file but only error with my "task.h" file and I do not see any differences in the #include rows between my "task.h" and all the other header files.
Part of Roundtrip C-file:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
/*XENOMAI*/
#include "task.h"
#include <rtdm/rtdm.h>
#include <asm/ioctl.h>
#define SERVER "192.168.127.10"
#define BUFLEN 512
#define PORT 8888
void die(char *s)
{
perror(s);
exit(1);
}
Part of task.h:
#ifndef _XENO_TASK_H
#define _XENO_TASK_H
#include <nucleus/sched.h>
#include <native/types.h>
/* Creation flags. */
#define T_FPU XNFPU
#define T_SUSP XNSUSP
/* <!> High bits must not conflict with XNFPU|XNSHADOW|XNSUSP. */
#define T_CPU(cpu) (1 << (24 + (cpu & 7))) /* Up to 8 cpus [0-7] */
#define T_CPUMASK 0xff000000
Part of another headerfile in the roundtrip c-file:
#ifndef _RTDM_H
#define _RTDM_H
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/socket.h>
typedef u32 socklen_t;
typedef struct task_struct rtdm_user_info_t;
#else /* !__KERNEL__ */
#include <fcntl.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
My makefile:
# Allow overriding xeno-config on make command line
XENO_CONFIG=xeno-config
prefix := $(shell $(XENO_CONFIG) --prefix)
ifeq ($(prefix),)
$(error Please add <xenomai-install-path>/bin to your PATH variable)
endif
CC := $(shell $(XENO_CONFIG) --skin=posix --cc)
STD_CFLAGS := $(shell $(XENO_CONFIG) --skin=posix --cflags) -g
STD_LDFLAGS := $(shell $(XENO_CONFIG) --skin=posix --ldflags) -g -lrtdm
STD_TARGETS := rtt_rt
all: $(STD_TARGETS)
$(STD_TARGETS): $(STD_TARGETS:%=%.c)
$(CC) -o $# $< $(STD_CFLAGS) $(STD_LDFLAGS)
clean:
$(RM) -f *.o *~ $(STD_TARGETS)
Trying to compile a very simple program for testing wiringpi's library for the hd44780 lcd controller:
#include <iostream>
#include <wiringPi.h>
#include <lcd.h>
...
int main()
{
init_wiringpi;
fd = lcdInit(2, 16, 4, 11,10 , 0,1,2,3,0,0,0,0) ;
...
return = 0;
}
Build Messages
LCD_first.cpp - undefined reference to `lcdInit'
LCD_first.cpp - undefined reference to `lcdPosition'
LCD_first.cpp - undefined reference to `lcdPuts'
Ok i just had to add lcd.o to the linked libraries list in Code::Blocks (settings/compiler/Linker settings/Link libraries >> /home/pi/wiringPi/devLib/lcd.o).
still working on this system call!!!
i have added a system call to a kernel, compiled and the OS is running off it.
now i am getting syntax error on the compilation of my test application.
testmycall.h
#include<linux/unistd.h>
#define __NR_mycall 244
_syscall1(long, mycall, int, i)
testmycall.c
#include<stdio.h>
#include "testmycall.h"
int main(int argc, char *argv[])
{
printf("%d\n", mycall(15));
}
here is the error
stef#ubuntu:~$ gcc -o testmycall testmycall.c
In file included from testmycall.c:3:
testmycall.h:7: error: expected ‘)’ before ‘mycall’
stef#ubuntu:~$ gcc -o testmycall testmycall.c
In file included from testmycall.c:3:
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘mycall’
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘i’
testmycall.c: In function ‘_syscall1’:
testmycall.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
testmycall.h:7: error: parameter name omitted
testmycall.h:7: error: parameter name omitted
testmycall.c:11: error: expected ‘{’ at end of input
stef#ubuntu
i have added in the syscall instead of _syscall1
now i get this error
stef#ubuntu:~$ gcc -o testmycall testmycall.c
testmycall.c: In function ‘syscall’:
testmycall.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
testmycall.c:11: error: expected ‘{’
this is the app, any ideas why???
I believe the _syscallN() macros were removed from the kernel headers around 2.6.18 or so.
The (not especially helpful) error messages from gcc are due to _syscall1 not being defined at all - you get the same errors if you write:
any_old_rubbish_here(long, mycall, int, i)
The syscall() function should work. man syscall for details.
The _syscall macros are obsolete and should not be used, instead use syscall, eg.
#define _GNU_SOURCE
#include <unistd.h>
...
printf("%d\n", syscall(__NR_mycall, 15));
Here's my test program:
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#define __NR_mycall 244
int main(int argc, char **argv)
{
printf("%d\n", syscall(__NR_mycall,15));
return 0;
}
The following works without error on OSX 10.6, but fails in the iphone simulator using SDK 4.1
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <string.h>
int main(void) {
int sock = socket(AF_UNIX, SOCK_DGRAM, 0);
struct sockaddr_un sock_addr;
memset(&sock_addr, 0, sizeof(struct sockaddr_un));
sock_addr.sun_family = AF_UNIX;
strcpy(sock_addr.sun_path, "/tmp/sock");
int err = bind(sock, (struct sockaddr*)&sock_addr, sizeof(struct sockaddr_un));
if(err == -1) {
perror("bind: ");
}
}
Error is "Address family not supported by protocol family"
Any ideas?
You really need to check sock already - most likely, the socket creation is what failed already.
My guess is that AF_UNIX/SOCK_DGRAM is not supported; try SOCK_STREAM instead.