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
Related
This is the following program.
#include <graphics.h>
int main(void)
{
drawRect(50,100,200,150);
drawLine(50,100,150,25);
drawLine(150,25,250,100);
drawRect(130,190,40,60);
drawRect(70,195,40,30);
drawRect(190,195,40,30);
drawRect(70,125,40,30);
drawRect(190,125,40,30);
return 0;
}
and following is the error
C:\Users\Balavardhan\Desktop\New folder\c language>gcc z.c -o z.exe
z.c: In function 'main':
z.c:4:6: warning: implicit declaration of function 'drawRect'; did you mean 'drawpoly'? [-Wimplicit-function-declaration]
drawRect(50,100,200,150);
^~~~~~~~
drawpoly
z.c:5:6: warning: implicit declaration of function 'drawLine'; did you mean 'drawpoly'? [-Wimplicit-function-declaration]
drawLine(50,100,150,25);
^~~~~~~~
drawpoly
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x2e): undefined reference to `drawRect'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x52): undefined reference to `drawLine'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x76): undefined reference to `drawLine'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x9a): undefined reference to `drawRect'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0xbe): undefined reference to `drawRect'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0xe2): undefined reference to `drawRect'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x106): undefined reference to `drawRect'
C:\Users\BALAVA~1\AppData\Local\Temp\ccMnl0ZM.o:z.c:(.text+0x12a): undefined reference to `drawRect'
collect2.exe: error: ld returned 1 exit status
Can anyone tell me how can I solve this problem?
Every time i try to compile SDL_net it says
SDLnet.c: In function 'SDLNet_GetLocalAddresses':
SDLnet.c:215:69: error: 'ERROR_BUFFER_OVERFLOW' undeclared (first use in this function)
if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == ERROR_BUFFER_OVERFLOW) {
^~~~~~~~~~~~~~~~~~~~~
SDLnet.c:215:69: note: each undeclared identifier is reported only once for each function it appears in
SDLnet.c:223:21: error: 'NO_ERROR' undeclared (first use in this function)
if (dwRetVal == NO_ERROR) {
^~~~~~~~
make: *** [SDLnet.lo] Error 1
https://www.vogons.org/viewtopic.php?f=31&t=55706#p609435
Use my Mingw guide, it's in the Google Drive link
I am following Assimp's documentation to retrieve properties from a struct aiMaterial type. From their documentation, this is the usage of aiGetMaterialString():
aiGetMaterialFloat(mat,<material-key>,<where-to-store>)
I was able to get the material name using aiGetMaterialString() and a propertie's color with aiGetMaterialColor(), for example, but adding this to my code:
float f = 1.0f;
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
results in:
gcc src/*.c examples/game.c -o bin/game.o -lGL -lGLEW -lSDL2 -lSDL2_image -lassimp -lm
In file included from /usr/include/assimp/scene.h:53:0,
from src/../include/mesh.h:13,
from src/mesh.c:1:
src/mesh.c: In function ‘mesh_setMaterialData’:
src/mesh.c:71:2: error: ‘pMat’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: note: each undeclared identifier is reported only once for each function it appears in
src/mesh.c:71:2: error: ‘type’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: ‘pKey’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: ‘pOut’ undeclared (first use in this function)
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
src/mesh.c:71:2: error: expected ‘;’ before ‘aiGetMaterialFloatArray’
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
^
make: *** [makefile:2: ALL] Error 1
(in my code, mat is of type struct aiMaterial*).
The code I am using is also basically the same thing that's described in assimp/material.h, line 1363:
float specStrength = 1.f; // default value, remains unmodified if we fail.
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS_STRENGTH,
(float*)&specStrength);
Could anyone explain to me what I am doing wrong?
Thank you.
Edit:
This is the definition of aiGetMaterialFloat
#define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)
and aiGetMaterialFloatArray
ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(const C_STRUCT aiMaterial* pMat, const char* pKey, unsigned int type, unsigned int index, float* pOut, unsigned int* pMax);
I replaced what I had earlier with:
aiGetMaterialFloatArray(mat, AI_MATKEY_SHININESS, &f, NULL);
and it compiles... If I swap around the arguments on this function call I can get gcc to tell me that the 4th argument I send is actually being perceived as the 6th for aiGetMaterialFloatArray (unsigned int* pMax). I really don't know enough about macros to understand what is going on.
Hey I am trying to connect to a database using postgres
#include <stdio.h>
#include <stdlib.h>
#include <libpq-fe.h>
int main(int argc, char* argv[])
{
//Start connection
PGconn* connection = PQconnectdb("host=webcourse.cs.nuim.ie dbname=cs621 sslmode=require user=ggales password=1234");
if (PQstatus(connection) ==CONNECTION_BAD)
{
printf("Connection error\n");
PQfinish(connection);
return -1; //Execution of the program will stop here
}
printf("Connection ok\n");
//End connection
PQfinish(connection);
printf("Disconnected\n");
return 0;
}
And I keep getting this compile error:
main.c: In function ‘main’:
main.c:9:35: warning: missing terminating " character [enabled by default]
main.c:9:2: error: missing terminating " character
main.c:10:2: error: ‘dbname’ undeclared (first use in this function)
main.c:10:2: note: each undeclared identifier is reported only once for each function it appears in
main.c:10:9: error: ‘cs621’ undeclared (first use in this function)
main.c:10:15: error: expected ‘)’ before ‘sslmode’
main.c:10:56: warning: missing terminating " character [enabled by default]
main.c:10:15: error: missing terminating " character
main.c:16:1: error: expected ‘,’ or ‘;’ before ‘}’ token
main.c:16:1: error: expected declaration or statement at end of input
Can anyone see why this is happening?
Thanks.
Your code compiles just fine. If I paste it into x.c I can compile it with no problems:
gcc -I /usr/pgsql-9.2/include -L /usr/pgsql-9.2/lib x.c -lpq
(paths may differ on your system).
you may use the 64-bit libpq.lib in a 32-bit program.
you can use a 32-bit libpq.lib or change you platform to x64.
a 32-bit client + 64-bit server can not work well.
I am using the Eclipse CDT and I have a goto label and a FILE definition after it and when I compile the project it gives me the error: Expression expected before FILE.
Thanks in advance,
Mr. Man
EDIT:
Ok, so this is what I get from the command line:
iOS.c: In function ‘main’:
iOS.c:45: error: expected expression before ‘FILE’
iOS.c:49: error: ‘preFile’ undeclared (first use in this function)
iOS.c:49: error: (Each undeclared identifier is reported only once
iOS.c:49: error: for each function it appears in.)`
And this is what code throws the error:
fileExists:
FILE *preFile = fopen("prefix.txt","r");
As you're coding in C, you need to declare the variable at the beginning of the function:
void foo()
{
FILE* preFile;
// some code
fileExists:
preFile = fopen("prefix.txt","r");
}