fatal error: stdio.matrixVector: File or directory not found - c

I'm trying to compile a C method
#include <stdio.matrixVector>
#include <gsl/gsl_matrix.matrixVector>
#include <gsl/gsl_math.matrixVector>
#include <gsl/gsl_multifit.matrixVector>
void myMethod(double vector[], double matrixVector[])
{
int n = sizeof(matrixVector)/sizeof(double);
gsl_matrix *X = gsl_matrix_calloc(n, 3);
gsl_vector *Y = gsl_vector_alloc(n);
gsl_vector *beta = gsl_vector_alloc(3);
for (int i = 0; i < n; i++) {
....
}
....
}
but I get this error
fatal error: stdio.matrixVector: File or directory not found
How could I fix this?

1- all the include are wrong
#include <stdio.matrixVector>
#include <gsl/gsl_matrix.matrixVector>
#include <gsl/gsl_math.matrixVector>
#include <gsl/gsl_multifit.matrixVector>
should be
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_multifit.h>
note that 3 include need the GNU Scientific Library, make sure to have installed it before compile the code
2- in the loop
for (int i = 0; i < n; i++) {
you have to declare i outside of the loop (if you aren't in C99 mode).

You need to change the #include lines, you've replaced all of the .h suffixes with .matrixVector in what I assume was a bulk replace for the rest of the file.
Change:
#include <stdio.matrixVector>
#include <gsl/gsl_matrix.matrixVector>
#include <gsl/gsl_math.matrixVector>
#include <gsl/gsl_multifit.matrixVector>
To:
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_multifit.h>

Related

a.at<uchar>(x,y) wont works in Vivado SDSoC

I want to get 2d array from a Mat in Vivado SDSoC but Im not able to do that because as described Xilinx(XAPP1167),
cv::Mat<>.at() method and cvGet2D() function have no corresponding equivalent
function in the synthesizable library
I appreciate any help. Thank you.
The project is about face recognition system. The system first will go viola-jone face detection and then feed the output to the CNN classification.
The output of viola-jones face detection is in unsigned char*.
I plant to convert it back to Mat and obtain 2d array for the input of CNN Classifier.
#include <cstdio>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <ctime>
#include <fcntl.h>
#include <fstream>
#include <iostream>
#include <sys/mman.h>
#include <malloc.h>
#include <unistd.h>
#include <sds_lib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/contrib/contrib.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/core/core_c.h"
using namespace cv;
using namespace std;
void resize_2_gray(unsigned char *imageIn, unsigned char *imageOut)
{
int k=0;
int coord;
for (int i=0; i<240; i++) {
for(int j=0; j<320; j++){
//coord=(i*2*640+j*2)*3;
#pragma HLS PIPELINE II=1
coord=6*(i*640+j);
imageOut[k] = 0.2126*imageIn[coord] + 0.7152*imageIn[coord+1] + 0.0722*imageIn[coord+2] ;
k++;
}
}
}
int main(){
Mat ROI;
unsigned int cam_num =5;//camera USB port
unsigned char *image_ROI;
image_ROI = (unsigned char*)sds_alloc(sizeof(unsigned char)*56*46);
VideoCapture stream(cam_num);
stream.read(ROI);
cvtColor(ROI,ROI, CV_BGR2RGB);
resize_2_gray(ROI.data, image_ROI);
double face_2darray [56][46]={0};
int h1=3, w1=3,w2=46,h2=56;
int x_ratio = (int)((w1<<16)/w2)+1;
int y_ratio = (int)((h1<<16)/h2)+1;
int x2,y2;
//resize image before fed into classification
for (int a=0;a<h2;a++)
{
for (int b=0;b<w2;b++)
{
x2=((b*x_ratio)>>16);
y2=((a*y_ratio)>>16);
image_ROI[(a*w2)+b]=ROI.data[(y2*w1)+x2];
face_2darray[a][b]=(double)image_ROI[a+b];
face_2darray[a][b]= 2*(face_2darray[a][b]/255)-1;
}
}
Mat Image = Mat(56,46,0,image_ROI);
imshow("Output",Image);
sds_free(image_ROI);
}
I believe the synthesized version is using a streaming interface, so you can't use random access APIs, and instead must read pixels/elements one by one.

C error in linking library

I am begginer in C and I have a problem with linking .c and .h files into main.c
I tried to link it and it looks like this in main.c :
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "hangman.h"
#include "hangman.c"
#include <string.h>
#include <time.h>
#include <ctype.h>
int main(void)
{
char secret[20];
srand(time(NULL));
getWord(secret);
hangman(secret);
return 0;
}
and like this in .c file
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include "hangman.h"
int isWordGuessed(const char secret[], const char lettersGuessed[]){
int pom = 0;
int i,j;
for(i = 0; i < strlen(secret); i++){
for (j= 0; j < strlen(lettersGuessed); j++)
{
if(secret[i] == lettersGuessed[j])
pom = 1;
}
if(pom == 1){
pom = 0;
}
else{
return 0;
}
}
return 1;
}
and like this in .h file
#define WORDLIST_FILENAME "words.txt"
int isWordGuessed(const char secret[], const char lettersGuessed[]);
Program just throws an exception. It tells me:
hangman.o: In function isWordGuessed':
hangman.c:(.text+0x0): multiple definition ofisWordGuessed'
main.o:main.c:(.text+0x0): first defined here
#include "hangman.h"
#include "hangman.c"
Do not include .c source files in your program. The include directive will simply copy hangman.c in your main.c.

Not able to call an extern function

I want to call a function that reside in my func.c file into my main.c
This is my func.c
#include "func.h"
int func(int i) {
return ++i ;
}
This is my header file func.h
int func(int i);
And this is my main code: main.c
#include <stdio.h>
#include <stdlib.h>
#include "func.h"
main()
{
int res = func(3);
printf("%d\n",res);
system("pause");
}
Compiling the main code I get the error: undefined reference to 'func'
My goal is to call function from an external file (that is not part of the same compilation unit).
How to do it? Thank you!
#include <stdio.h>
#include <stdlib.h>
#include "func.h" // change ( since func.h is not a slandered header file its a user define header file)
main()
{
int res = func(3);
printf("%d\n",res);
system("pause");
}

character array to floating point conversion

I am trying to convert the output buffer(character array)
of the code below to floating point format for further calculations.
Can anybody tell me how to do it.
#include "usbtmc.h"
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <inttypes.h>
#include <sys/types.h>
#include <pthread.h>
int main()
{
int myfile;
char buffer[4000];
int actual;
myfile=open("/dev/usbtmc1",O_RDWR);
if(myfile>0)
{
system("echo MEAS:VOLT:AC?>/dev/usbtmc1");
actual=read(myfile,buffer,4000);
buffer[actual] = 0;
printf("Response = \n %s\n",buffer);
close(myfile);
}
return 0;
}
The sample output for this code is
Response =
+1.29273072E-04
You may have two ways:
using double atof(const char* str)
float f;
f = (float)atof(buffer);
printf("%f",f); // here you can use f
using int sscanf( const char * s, const char * format, ...)
float f;
sscanf(buffer,"%f",&f);
printf("%f",f); // here you can use f

extern declarations and header files in C

I was looking at this question here :
How do I use extern to share variables between source files?
followed the manual . but still I get Linker errors ...
Would love to get some help and explanation why it happens..
I have 2 .c files and one header file :
------check.h----
#ifndef check
#define check
extern int num;
#endif
----check.c----
#include "check.h"
#include <stdio.h>
int func(int x, int y)
{
int z = x+y;
return z;
}
void printnum()
{
num++;
printf("%d",num);
}
----ynnynyny.c----
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "check.h"
#include "check.c"
int num = 10;
int main()
{
printf("num before is : %d\n",num);
printnum();
printf("num now is : %d",num);
getchar();
return 0;
}
I keep getting these errors :
1> ynnyny.c
1> check.c
1> Generating Code...
1>ynnyny.obj : error LNK2005: _func already defined in check.obj
1>ynnyny.obj : error LNK2005: _printnum already defined in check.obj
I wrote the #ifndef stuff and also the extern declaration, so what Is the problem?
thanks!
don't include "check.c" in ynnynyny.c

Resources