#include <mxml.h>
#include <stdio.h>
void main()
{
FILE *fp;
mxml_node_t *tree;
mxml_node_t *node = NULL;
fp = fopen("1.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
node = tree;
fprintf(stderr, "Element::%s\n", mxmlGetElement(node));
fprintf(stderr, "Value::%s\n", mxmlGetText(node, 0));
}
Above is My Code snippet ... Error is
xmlparsing.c: In function ‘main’:
xmlparsing.c:20:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
xmlparsing.c:21:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
/tmp/ccAYsMOB.o: In function `main':
xmlparsing.c:(.text+0x58): undefined reference to `mxmlGetElement'
xmlparsing.c:(.text+0x8c): undefined reference to `mxmlGetText'
collect2: ld returned 1 exit status
Already included the mxml.h than why undefined reference? I searched about this functions on the Internet, and links show me that it's in mxml.h header file.
Your problem is with your Linker, see that last message:
collect2: ld returned 1 exit status
You need to inform the gcc (which is a call to a compiler and linker about the include path and the library path.
The include path is where mxml.h is found, this will be done with:
-I<path/to/include/mxml.h>
The library path is given with:
-L<path/to/shared/libmxml.a>
So in total you should have:
gcc yourfile.c -I <path/to/include/mxml.h> -L <path/to/shared/libmxml.a>
You can include other paths as needed.
Related
The code here is a code from a website. Since I was facing an issue with my origin code, I ended up trying this implementation from a website. But turns out I have the same issue with this program too
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
FILE *fptr;
if ((fptr = fopen("D:\\TestFile\\test.txt","r")) == NULL){
printf("Error! opening file\n");
perror(fptr);
// Program exits if the file pointer returns NULL.
exit(1);
}
fscanf(fptr,"%d", &num);
printf("Value of n=%d\n", num);
printf("%s\n", fptr);
fclose(fptr);
return 0;
}
I am stuck with the if condition i.e., whatever I do I am not able to read the file except the root directory. Even though I specify the path, it still looks for the file under root directory.
I am not sure why it's not working, provided the same code works fine in Linux
I see 2 mistakes, the one related to perror mentioned in the comments, and the last printf. Now if the program is still not working, it could be interesting to check the error or to get the program output.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
FILE *fptr;
if ((fptr = fopen("D:\\TestFile\\test.txt","r")) == NULL){
// printf("Error! opening file\n");
// perror(fptr); // MISTAKE-1: perror parameter is a string
perror("Error! opening file");
// Program exits if the file pointer returns NULL.
exit(1);
}
fscanf(fptr,"%d", &num);
printf("Value of n=%d\n", num);
//printf("%s\n", fptr); // MISTAKE-2: fptr is not a string
fclose(fptr);
return 0;
}
the posted code does not cleanly compile!
Here is the results of compiling with many of the warnings enabled:
gcc -ggdb3 -Wall -Wextra -Wconversion -pedantic -std=gnu11 -c "untitled1.c" -o "untitled1.o"
untitled1.c: In function ‘main’:
untitled1.c:11:16: warning: passing argument 1 of ‘perror’ from incompatible pointer type [-Wincompatible-pointer-types]
11 | perror(fptr);
| ^~~~
| |
| FILE * {aka struct _IO_FILE *}
In file included from untitled1.c:1:
/usr/include/stdio.h:775:33: note: expected ‘const char *’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
775 | extern void perror (const char *__s);
| ~~~~~~~~~~~~^~~
untitled1.c:19:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘FILE *’ {aka ‘struct _IO_FILE *’} [-Wformat=]
19 | printf("%s\n", fptr);
| ~^ ~~~~
| | |
| | FILE * {aka struct _IO_FILE *}
| char *
Compilation finished successfully.
Note; the statement: Compilation finished successfully. just means the compiler applied some work around to each of the problems. It does NOT mean the correct code was produced.
I would like to pass the integrated gpu from the host os (ubuntu 20.04) to the windows 10 guest os with xen. This is because xen works great for me,better than qemu-kvm for my specific needs and because I have only two graphic cards. The nvidia rtx 2080 ti that I have already passed to the guest,and the intel UHD 630,that can be duplicated from the host to the guest so that it can be used in both places without interruptions. So I'm trying to build this repository :
https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#332-build-qemu--xen-for-xengt
exploring the log,I see this situation :
config-temp/qemu-conf.c:1:10: fatal error: sys/endian.h: File o directory non esistente
1 | #include <sys/endian.h>
| ^~~~~~~~~~~~~~
compilation terminated.
/usr/bin/ld: /tmp/cc6WBNSk.o: in function `main':
/etc/xen/igvtg-xen/tools/qemu-xen-build/config-temp/qemu-conf.c:2: undefined reference to `sin'
collect2: error: ld returned 1 exit status
/usr/bin/ld: /tmp/ccEQrVtw.o: in function `main':
/etc/xen/igvtg-xen/tools/qemu-xen-build/config-temp/qemu-conf.c:4: undefined reference to `timer_create'
collect2: error: ld returned 1 exit status
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:2:25: warning: null argument where non-null required (argument 1) [-Wnonnull]
2 | int main(void) { return sem_timedwait(0, 0); }
| ^~~~~~~~~~~~~
config-temp/qemu-conf.c:2:25: warning: null argument where non-null required (argument 2) [-Wnonnull]
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:2:25: error: null argument where non-null required (argument 1) [-Werror=nonnull]
2 | int main(void) { return sem_timedwait(0, 0); }
| ^~~~~~~~~~~~~
config-temp/qemu-conf.c:2:25: error: null argument where non-null required (argument 2) [-Werror=nonnull]
It seems that the compilation stops because this :
config-temp/qemu-conf.c:1:10: fatal error: sys/endian.h: File o directory non esistente
1 | #include <sys/endian.h>
| ^~~~~~~~~~~~~~
compilation terminated.
This is the qemu-conf.c file :
root#ziomario-z390aoruspro:/etc/xen/igvtg-xen/tools/qemu-xen-build/config-temp# nano qemu-conf.c
include <semaphore.h>
int main(void) { return sem_timedwait(0, 0); }
Someone of you can help me to fix this bug ? thanks.
endian.h is normaly located directly under includes/ in linux.
You've got to have the glibc headers installed and change the source file(s) to #include <endian.h> instead.
I'm running Cygwin on top of Windows 7. I'm having trouble trying to install the checkinstall utility from source, and the culprit appears to be gcc.
When I run /.configure, I get the error:
-bash: ./configure: No such file or directory
So I continue with make, and get output that fails with lots of errors, presumably caused by gcc. The output can be seen in its entirety here, but below are the first and last few lines of it.
$ make
for file in locale/checkinstall-*.po ; do \
case ${file} in \
locale/checkinstall-template.po) ;; \
*) \
out=`echo $file | sed -s 's/po/mo/'` ; \
msgfmt -o ${out} ${file} ; \
if [ $? != 0 ] ; then \
exit 1 ; \
fi ; \
;; \
esac ; \
done
make -C installwatch
make[1]: Entering directory '/cygdrive/b/Users/Me/Desktop/checkinstall-1.6.2/installwatch'
gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DVERSION=\"0.7.0beta7\" installwatch.c
In file included from /usr/local/include/sys/param.h:33:0,
from installwatch.c:31:
/usr/local/include/sys/types.h:10:2: error: #error Only Win32 target is supported!
#error Only Win32 target is supported!
^~~~~
In file included from /usr/local/include/sys/param.h:33:0,
from installwatch.c:31:
/usr/local/include/sys/types.h:90:3: error: unknown type name ‘time_t’
time_t tv_sec; /* Seconds */
^~~~~~
In file included from installwatch.c:33:0:
/usr/local/include/sys/stat.h:10:2: error: #error Only Win32 target is supported!
#error Only Win32 target is supported!
^~~~~
In file included from /usr/local/include/sys/stat.h:14:0,
from installwatch.c:33:
/usr/local/include/io.h:199:28: error: expected ‘,’ or ‘;’ before ‘_findfirst32’
_CRTIMP intptr_t __cdecl _findfirst32(const char *_Filename,struct _finddata32_t *_FindData);
^~~~~~~~~~~~
...
installwatch.c: In function ‘fopen’:
installwatch.c:2560:51: error: expected ‘)’ before ‘result’
logg("%" PRIdPTR "\tfopen\t%s\t#%s\n",(intptr_t)result,
^~~~~~
installwatch.c:2560:8: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
logg("%" PRIdPTR "\tfopen\t%s\t#%s\n",(intptr_t)result,
^~~
installwatch.c:2560:8: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
installwatch.c:2575:51: error: expected ‘)’ before ‘result’
logg("%" PRIdPTR "\tfopen\t%s\t#%s\n",(intptr_t)result,
^~~~~~
installwatch.c:2575:8: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
logg("%" PRIdPTR "\tfopen\t%s\t#%s\n",(intptr_t)result,
^~~
installwatch.c:2575:8: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
installwatch.c: At top level:
installwatch.c:2600:7: error: conflicting types for ‘getcwd’
char *getcwd(char *buffer,size_t size) {
^~~~~~
In file included from /usr/local/include/sys/stat.h:14:0,
from installwatch.c:33:
/usr/local/include/io.h:279:17: note: previous declaration of ‘getcwd’ was here
char *__cdecl getcwd (char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~~
installwatch.c:2664:30: error: unknown type name ‘uid_t’
int lchown(const char *path, uid_t owner, gid_t group) {
^~~~~
installwatch.c:2664:43: error: unknown type name ‘gid_t’
int lchown(const char *path, uid_t owner, gid_t group) {
^~~~~
installwatch.c:2749:5: error: conflicting types for ‘mkdir’
int mkdir(const char *pathname, mode_t mode) {
^~~~~
In file included from /usr/local/include/sys/stat.h:14:0,
from installwatch.c:33:
/usr/local/include/io.h:280:15: note: previous declaration of ‘mkdir’ was here
int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~
installwatch.c:2983:7: error: conflicting types for ‘realpath’
char *realpath(const char *file_name,char *resolved_name) {
^~~~~~~~
installwatch.c:556:6: note: previous implicit declaration of ‘realpath’ was here
if(!realpath(path,resolved_path)) {
^~~~~~~~
installwatch.c:3309:5: error: conflicting types for ‘utime’
int utime (const char *pathname, const struct utimbuf *newtimes) {
^~~~~
In file included from /usr/local/include/utime.h:6:0,
from installwatch.c:47:
/usr/local/include/sys/utime.h:115:26: note: previous definition of ‘utime’ was here
__CRT_INLINE int __cdecl utime(const char *_Filename,struct utimbuf *_Utimbuf) {
^~~~~
installwatch.c: In function ‘true_stat’:
installwatch.c:153:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
installwatch.c: In function ‘true_lstat’:
installwatch.c:161:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
installwatch.c: In function ‘true_mknod’:
installwatch.c:157:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
In file included from installwatch.c:35:0:
installwatch.c: In function ‘open’:
installwatch.c:2842:20: warning: ‘mode_t {aka short unsigned int}’ is promoted to ‘int’ when passed through ‘...’
mode = va_arg(ap, mode_t);
^
installwatch.c:2842:20: note: (so you should pass ‘int’ not ‘mode_t {aka short unsigned int}’ to ‘va_arg’)
installwatch.c:2842:20: note: if this code is reached, the program will abort
At top level:
installwatch.c:1040:12: warning: ‘__instw_printdirent64’ defined but not used [-Wunused-function]
static int __instw_printdirent64(struct dirent64 *entry) {
^~~~~~~~~~~~~~~~~~~~~
make[1]: *** [Makefile:22: installwatch.o] Error 1
make[1]: Leaving directory '/cygdrive/b/Users/Me/Desktop/checkinstall-1.6.2/installwatch'
make: *** [Makefile:11: all] Error 2
I'm sorry in advance if I'm going about this the wrong way, but I'm completely out of my depth with this code and the errors being thrown. I've tried using the Cygwin installer to reinstall gcc_core and other gcc packages several times to no effect.
I was in the process of using this guide to compile the latest version of gcc from source before I ran into fatal errors with that too, and decided to start from the beginning and determine whether the problem can be solved without adding yet more bloat to my Cygwin installation. Thanks in advance, it's much appreciated.
The checkinstall app does not appear to be configured to run on cygwin. It is configured for several specific Linux distribution families, and has a generic source release.
I have downloaded and unpacked the checkinstall-1.6.2.tar.gz file; it expands into the checkinstall-1.6.2 directory. There you find the checkinstall shell script. I don't have the time to wade through several thousand lines of shell code. It appears to require you build and install the installwatch program, which I guess will register a file change handler in order to identify all new and changed files and directories. I suspect that handler would need to change to work properly in cygwin. You might have success posting to one of the Cygwin mailing lists.
HTH
Doug
I have been working on a C code for which I needed some functions of libxls.h header files. I have already downloaded the corresponding files and followed the installation instruction. The files also contained a test C code (test.c) which I tried compiling. The results were as follow:
Command to compile the test.c file-
gcc test.c -lm
Results:
[root#XXXXXXX95549 test]# gcc test.c -lm
test.c:28:24: error: libxls/xls.h: No such file or directory
test.c: In function ‘main’:
test.c:33: error: ‘xlsWorkBook’ undeclared (first use in this function)
test.c:33: error: (Each undeclared identifier is reported only once
test.c:33: error: for each function it appears in.)
test.c:33: error: ‘pWB’ undeclared (first use in this function)
test.c:34: error: ‘xlsWorkSheet’ undeclared (first use in this function)
test.c:34: error: ‘pWS’ undeclared (first use in this function)
test.c:39: error: ‘WORD’ undeclared (first use in this function)
test.c:39: error: expected ‘;’ before ‘t’
test.c:53: error: ‘t’ undeclared (first use in this function)
test.c:58: error: ‘tt’ undeclared (first use in this function)
test.c:60: error: dereferencing pointer to incomplete type
test.c:63: error: dereferencing pointer to incomplete type
test.c:64: error: dereferencing pointer to incomplete type
test.c:66: error: dereferencing pointer to incomplete type
test.c:67: error: dereferencing pointer to incomplete type
test.c:68: error: dereferencing pointer to incomplete type
test.c:70: error: dereferencing pointer to incomplete type
test.c:70: error: dereferencing pointer to incomplete type
test.c:71: error: dereferencing pointer to incomplete type
To solve this problem, I copied the library files at the '/user/include' location
After which the results for same compilation commands were:
[root#XXXXXX95549 test]# gcc test.c -lm
/tmp/cc8DJETV.o: In function `main':
test.c:(.text+0x14): undefined reference to `xls_open'
test.c:(.text+0xd4): undefined reference to `xls_getWorkSheet'
test.c:(.text+0xe4): undefined reference to `xls_parseWorkSheet'
test.c:(.text+0xf0): undefined reference to `xls_getCSS'
test.c:(.text+0x49c): undefined reference to `xls_showBookInfo'
collect2: ld returned 1 exit status
Please, explain how can I rectify this problem.
The code test.c is given below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libxls/xls.h>
int main()
{
xlsWorkBook* pWB;
xlsWorkSheet* pWS;
FILE *f;
int i;
struct st_row_data* row;
WORD t,tt;
pWB=xls_open("files/test2.xls", "ASCII"); // "KOI8-R"
if (pWB!=NULL)
{
f=fopen ("test.htm", "w");
for (i=0;i<pWB->sheets.count;i++)
printf("Sheet N%i (%s) pos %i\n",i,pWB->sheets.sheet[i].name,pWB->sheets.sheet[i].filepos);
pWS=xls_getWorkSheet(pWB,0);
xls_parseWorkSheet(pWS);
fprintf(f,"<style type=\"text/css\">\n%s</style>\n",xls_getCSS(pWB));
fprintf(f,"<table border=0 cellspacing=0 cellpadding=2>");
for (t=0;t<=pWS->rows.lastrow;t++)
{
row=&pWS->rows.row[t];
// xls_showROW(row->row);
fprintf(f,"<tr>");
for (tt=0;tt<=pWS->rows.lastcol;tt++)
{
if (!row->cells.cell[tt].ishiden)
{
fprintf(f,"<td");
if (row->cells.cell[tt].colspan)
fprintf(f," colspan=%i",row->cells.cell[tt].colspan);
// if (t==0) fprintf(f," width=%i",row->cells.cell[tt].width/35);
if (row->cells.cell[tt].rowspan)
fprintf(f," rowspan=%i",row->cells.cell[tt].rowspan);
fprintf(f," class=xf%i",row->cells.cell[tt].xf);
fprintf(f,">");
if (row->cells.cell[tt].str!=NULL && row->cells.cell[tt].str[0]!='\0')
fprintf(f,"%s",row->cells.cell[tt].str);
else
fprintf(f,"%s"," ");
fprintf(f,"</td>");
}
}
fprintf(f,"</tr>\n");
}
fprintf(f,"</table>");
printf("Count of rows: %i\n",pWS->rows.lastrow);
printf("Max col: %i\n",pWS->rows.lastcol);
printf("Count of sheets: %i\n",pWB->sheets.count);
fclose(f);
xls_showBookInfo(pWB);
}
return 0;
}
Thanks in advance,
Got the answer to this question on the following location:
http://www.cprogramdevelop.com/2018568/
Those who might be facing the problem with libxls library can refer the above mentioned website.
cheers
I am trying to compile PJSIP 2.1 with Video support on Ubuntu but I get the following error when running 'make' :
In file included from ../src/pjmedia/ffmpeg_util.c:26:0:
../src/pjmedia/ffmpeg_util.h:50:12: warning: ‘enum CodecID’ declared inside parameter list [enabled by default]
enum CodecID *codec_id);
^
../src/pjmedia/ffmpeg_util.h:50:12: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
../src/pjmedia/ffmpeg_util.h:53:7: warning: ‘enum CodecID’ declared inside parameter list [enabled by default]
pjmedia_format_id *fmt_id);
^
../src/pjmedia/ffmpeg_util.c:65:18: error: field ‘codec_id’ has incomplete type
enum CodecID codec_id;
^
../src/pjmedia/ffmpeg_util.c:167:13: error: conflicting types for ‘pjmedia_format_id_to_CodecID’
pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
^
In file included from ../src/pjmedia/ffmpeg_util.c:26:0:
../src/pjmedia/ffmpeg_util.h:49:13: note: previous declaration of ‘pjmedia_format_id_to_CodecID’ was here
pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
^
../src/pjmedia/ffmpeg_util.c: In function ‘pjmedia_format_id_to_CodecID’:
../src/pjmedia/ffmpeg_util.c:173:35: warning: comparison between pointer and integer [enabled by default]
if (t->id==fmt_id && t->codec_id != PIX_FMT_NONE) {
^
../src/pjmedia/ffmpeg_util.c:174:6: error: dereferencing pointer to incomplete type
*codec_id = t->codec_id;
^
../src/pjmedia/ffmpeg_util.c:174:6: warning: statement with no effect [-Wunused-value]
../src/pjmedia/ffmpeg_util.c:179:5: error: dereferencing pointer to incomplete type
*codec_id = PIX_FMT_NONE;
^
../src/pjmedia/ffmpeg_util.c:179:5: warning: statement with no effect [-Wunused-value]
../src/pjmedia/ffmpeg_util.c: At top level:
../src/pjmedia/ffmpeg_util.c:183:55: error: parameter 1 (‘codec_id’) has incomplete type
pj_status_t CodecID_to_pjmedia_format_id(enum CodecID codec_id,
^
make[2]: *** [output/pjmedia-i686-pc-linux-gnu/ffmpeg_util.o] Error 1
make[2]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make[1]: *** [pjmedia] Error 2
make[1]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make: *** [all] Error 1
I have installed the required dependencies and have no idea what the problem is. Reading the error messages it looks like it comes from error in the PJSIP code?
EDIT : I renamed enum CodecID to enum AVCodecID according to Getting “field has incomplete type” and "conflicting types" but now i'm getting the following error :
../lib/libpjmedia-codec-i686-pc-linux-gnu.a(ffmpeg_vid_codecs.o): In function `ffmpeg_codec_encode_whole.isra.7':
ffmpeg_vid_codecs.c:(.text+0x1374): undefined reference to `avcodec_encode_video2'
collect2: error: ld returned 1 exit status
make[2]: *** [../bin/pjmedia-test-i686-pc-linux-gnu] Error 1
make[2]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make[1]: *** [pjmedia-test] Error 2
make[1]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make: *** [all] Error 1
Seems that you miss libavcodec/avcodec.h and, most probably, also libavformat/avformat.h. This should be because ffmpeg include folder is not into gcc's list of directories to look for header files.
From your update seems that pjsip is building against a newer ffmpeg version that the one available in Ubuntu's repositories. As you've built it yourself, you can configure pjsip to use your version by running:
./configure --with-ffmpeg=<YOUR_FFMPEG_FOLDER>
or
#Copy all library ffmpeg library files into one folder
CFLAGS="-I<YOUR_FFMPEG_FOLDER>" LDFLAGS="-L<YOUR_FFMPEG_LIB_FOLDER>" ./configure
The answer to the original question :
While compiling PJSIP I find that CodecID enum has been deprecated from ffmpeg. However it's been replaced by AV_CodecID and also the enum values have a leading AV_ added to them.
Thus after changing CodecID to AV_CodecID, please change the enums in ffmpeg_util.c.
For example this is what the table looks like after the change :
/* Conversion table between pjmedia_format_id and CodecID */
static const struct ffmpeg_codec_table_t
{
pjmedia_format_id id;
enum AVCodecID codec_id;
} ffmpeg_codec_table[] =
{
{PJMEDIA_FORMAT_H261, AV_CODEC_ID_H261},
{PJMEDIA_FORMAT_H263, AV_CODEC_ID_H263},
{PJMEDIA_FORMAT_H263P, AV_CODEC_ID_H263P},
{PJMEDIA_FORMAT_H264, AV_CODEC_ID_H264},
{PJMEDIA_FORMAT_MPEG1VIDEO, AV_CODEC_ID_MPEG1VIDEO},
{PJMEDIA_FORMAT_MPEG2VIDEO, AV_CODEC_ID_MPEG2VIDEO},
{PJMEDIA_FORMAT_MPEG4, AV_CODEC_ID_MPEG4},
{PJMEDIA_FORMAT_MJPEG, AV_CODEC_ID_MJPEG}
};