Notices


Reply
Thread Tools
Posts: 11 | Thanked: 0 times | Joined on Oct 2010
#1
Hello!!!
I have a problem, I am working with ESBox 's Maemo 5
with a virtual machine, and when I create a new project c basing on the template 'hello world (make)' and I delete it and I write this lines:

#include <stdio.h>
#include <clockd/libtime.h>

int main(void){

int i;

time_t tinicial=time_get_time();

for(i=0;i<400000;i++){
printf("Hola!");
}

time_t tfinal=time_get_time();

double segundos=difftime(tinicial,tfinal);

return 0;
}


I have an error: undefined reference to 'time_get_time'
I modify the makefile handly and I put the completes routes until the file 'clockd' and I add in Project->Properties->C/c++ Paths and Symbols y ahí, in GNU C, the complete route too. So it work ok
but then I deleted all that I had add in the makefile and then it work so good.... ¿what is the problem?

¿what is the difference to file 'helloworld' and 'helloworld (make)'?
¿why with 'helloworld' recognize the comments types '//' and with the 'helloworld make' not (only recognize the comments types '/**/'?
¿why doesn't recongnize the files .h library gsgstreamer-0.10/gst/gst.h defined in gst.h and not recognize its functiions?

¿why if I use the same code program whit 'helloworld' and 'helloworld (make)' not have got the same behaviour? for example the code is:
#include <stdio.h>
#include <time.h>

int main(void){

int i;

clock_id c= CLOCK_MONOTONIC;

struct timespec tinicial,tfinal;

int ti=clock_gettime(c,&tinicial);


for(i=0;i<400000;i++){
printf("Hola!");
}

int tf = clock_gettime(c,&tfinal);

double segundos= difftiem(tfinal.tv_sec,tinicial.tv_nsec);
long nanosegundos= tfinal.tv_nsec-tinicial.tv_nsec;

return 0;
}

Well ... with the template 'helloworld make' I have to add '#include <sys/types.h> because it doesnt recognize the type 'clock_id' but with 'helloworld' NOT

With the template 'helloword make' It not compile because it not recognize but with 'helloword' is all OK ¿why is the problem??

I am going crazy , HELP PLEASE!!!!

sorry for my bad english
 
Posts: 317 | Thanked: 787 times | Joined on Oct 2009 @ Krakow, Poland
#2
Originally Posted by rosiflower View Post
¿why with 'helloworld' recognize the comments types '//' and with the 'helloworld make' not (only recognize the comments types '/**/'?
This looks like there are some additional flags added to gcc calls (somewhere in the makefile, propably in CFLAGS line). If you have "-ansi" or "-std=c89" then C++ style comments will not work. Remove this flag and you should be fine.

Originally Posted by rosiflower View Post
¿why doesn't recongnize the files .h library gsgstreamer-0.10/gst/gst.h defined in gst.h and not recognize its functiions?
This one looks like linking problem. It is not sufficient to only have a header for library included in source file for many libraries. You also have to link with that library. To do that you have to extend LIBS line in your makefile. For example if you want to use math functions you add #include <math.h> to your source file and LIBS=-lm to your makefile.

For many libraries the correct way to add their linking parameters is to use their config script. Try adding something similiar to `gst-config --cflags --libs` to your LIBS line. Hope this helps.
 

The Following User Says Thank You to dwaradzyn For This Useful Post:
Posts: 11 | Thanked: 0 times | Joined on Oct 2010
#3
Thank you very much!!!

I could resolve my problem with the comments '//' that OK


--------------------------------------------------------------
but with library 'gstreamer-0.10/gst/gst.h' I am going having problem. With 'helloworld (make)' it says this error:

Package gst was not found in the pkg-config search path.
Perhaps you should add the directory containing `gst.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gst' found
In file included from src/main.c:12:
/usr/include/gstreamer-0.10/gst/gst.h:29:29: error: gst/glib-compat.h: No such file or directory
/usr/include/
[...]
src/main.c: In function 'main':
src/main.c:18: error: 'GstClock' undeclared (first use in this function)
src/main.c:18: error: (Each undeclared identifier is reported only once
[...]

I wrote in the 'makefile' this:

CFLAGS = -g -O0 -I/usr/include/gstreamer-0.10/gst
PKGCFLAGS = `pkg-config --cflags gstreamer-0.10 gst`
LIBS = `pkg-config --libs gstreamer-0.10 gst` -ltime -lgstreamer-0.10 -lg -lgst

and too DESESPERADAMENTE I add this :
PKG_CONFIG_PATH = `pkg-config --cflags gstreamer-0.10 gst`

and this it's all
---------------------------------------------
and with 'helloworld' it says this error:

In file included from src/main.c:16:
/usr/include/gstreamer-0.10/gst/gst.h:29:29: error: gst/glib-compat.h: No such file or directory
/usr/include/gstreamer-0.10/gst/gst.h:31:30: error: gst/gstenumtypes.h: No such file or directory
[...]
src/main.c: In function 'main':
src/main.c:21: error: 'GstClock' undeclared (first use in this function)
src/main.c:21: error: (Each undeclared identifier is reported only once
src/main.c:21: error: for each function it appears in.)
src/main.c:21: error: expected ';' before 'c'
src/main.c:24: error: 'GstClockTime' undeclared (first use in this function)
[...]
src/main.c:33: error: 'GstClockTimeDiff' undeclared (first use in this function)


I wrote in the 'makefile' this:

DEPS_CFLAGS =-I/usr/lib/gstreamer-0.10/gst
DEPS_LIBS = -lgstreamer-0.10 -lgst -ltime
HILDON_CFLAGS =-I/usr/lib/gstreamer-0.10/gst
HILDON_LIBS = -lgstreamer-0.10 -lgst -ltime
LIBS = -lgstreamer-0.10 -lgst -lg
OSSO_CFLAGS =-I/usr/lib/gstreamer-0.10/gst
OSSO_LIBS = -lgstreamer-0.10 -lgst -ltime

------------------------------------------------
 
Reply


 
Forum Jump


All times are GMT. The time now is 05:52.