including own header files

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

including own header files

Carl Immanuel Manalo
hi. i posted before about trying to include my own header files in a C code. my problem with it is that it couldn't find the header file i'm trying to include

#include "matrix.h"

i got the code from one of my groupmates who used a make file to compile it. it works perfectly for her, but it doesn't work for me. even if i placed the matrix.h file in the same folder as the source files, it still doesn't work. someone suggested putting the path of the include folder into the make file. since i'm new to make files, i don't know where to put it. what i tried though is put the path in this line

IDIR =../include

which i'm assuming is the path to the include folder. it didn't work. below is the complete make file. perhaps there is something there you guys could see but i don't.Ü thank you.Ü

IDIR =../include
CC=gcc
CFLAGS=-I$(IDIR)

ODIR=obj
LDIR =../lib

_DEPS = matrix.h configfile.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))

_OBJ = matcreat.o matdump.o materr.o matadd.o matsub.o \
matmul.o matinv.o matsolve.o mattran.o matdet.o mattoepz.o matdurbn.o matsubx.o \
matconvert.o matsmul.o\
add_control_noise.o compute_steering.o get_observations.o mathfunc.o observe_heading.o \
pi_to_pi.o predict.o add_observation_noise.o\
vehicle_model.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))

$(ODIR)/%.o: %.c $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

ekfslam: ekfslam.c $(OBJ)
    gcc -o $@ $^ $(CFLAGS) -lm

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same.
Reply | Threaded
Open this post in threaded view
|

Re: including own header files

JonY-2
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
_______________________________________________
On 11/21/2008 17:04, Carl Immanuel Manalo wrote:

> hi. i posted before about trying to include my own header files in a C code.
> my problem with it is that it couldn't find the header file i'm trying to
> include
>
> #include "matrix.h"
>
> i got the code from one of my groupmates who used a make file to compile it.
> it works perfectly for her, but it doesn't work for me. even if i placed the
> matrix.h file in the same folder as the source files, it still doesn't work.
> someone suggested putting the path of the include folder into the make file.
> since i'm new to make files, i don't know where to put it. what i tried
> though is put the path in this line
>
> IDIR =../include
>
> which i'm assuming is the path to the include folder. it didn't work. below
> is the complete make file. perhaps there is something there you guys could
> see but i don't.Ü thank you.Ü
>
> IDIR =../include
> CC=gcc
> CFLAGS=-I$(IDIR)
>
> ODIR=obj
> LDIR =../lib
>
> _DEPS = matrix.h configfile.h
> DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
>
> _OBJ = matcreat.o matdump.o materr.o matadd.o matsub.o \
> matmul.o matinv.o matsolve.o mattran.o matdet.o mattoepz.o matdurbn.o
> matsubx.o \
> matconvert.o matsmul.o\
> add_control_noise.o compute_steering.o get_observations.o mathfunc.o
> observe_heading.o \
> pi_to_pi.o predict.o add_observation_noise.o\
> vehicle_model.o
> OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
>
> $(ODIR)/%.o: %.c $(DEPS)
>      $(CC) -c -o $@ $<  $(CFLAGS)
>
> ekfslam: ekfslam.c $(OBJ)
>      gcc -o $@ $^ $(CFLAGS) -lm
>
> .PHONY: clean
>
> clean:
>      rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
>
>

Hi,
Its possible that it is make that can't find it instead of gcc. You can
try removing matrix.h from the _DEPS line.

What was the error message anyway?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: including own header files

Carl Immanuel Manalo
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
_______________________________________________

hello again here is the compile output when i type "mingw32-make" in the command line.Ü oh. i also forget to mention that my classmate was using the gcc with ubuntu.

gcc -o ekfslam ekfslam.c obj/matcreat.o obj/matdump.o obj/materr.o obj/matadd.o
obj/matsub.o obj/matmul.o obj/matinv.o obj/matsolve.o obj/mattran.o obj/matdet.
 obj/mattoepz.o obj/matdurbn.o obj/matsubx.o obj/matconvert.o obj/matsmul.o obj
add_control_noise.o obj/compute_steering.o obj/mathfunc.o obj/pi_to_pi.o obj/pr
dict.o obj/vehicle_model.o -I../include -lm
C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0xab): undefined ref
rence to `_toMatrix'
C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0xbc): undefined ref
rence to `_toMatrix'
C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0x1b4): undefined re
erence to `_vehicle_model'
C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0x26d): undefined re
erence to `_predict'
obj/matinv.o: In function `mat_inv':
matinv.c:(.text+0x19): undefined reference to `mat_copy'
matinv.c:(.text+0x37): undefined reference to `mat_creat'
matinv.c:(.text+0x54): undefined reference to `mat_creat'
matinv.c:(.text+0x72): undefined reference to `mat_creat'
matinv.c:(.text+0x97): undefined reference to `mat_free'
matinv.c:(.text+0xa2): undefined reference to `mat_free'
matinv.c:(.text+0xad): undefined reference to `mat_free'
matinv.c:(.text+0xb8): undefined reference to `mat_free'
matinv.c:(.text+0xe0): undefined reference to `mat_fill'
matinv.c:(.text+0x12d): undefined reference to `mat_free'
matinv.c:(.text+0x138): undefined reference to `mat_free'
matinv.c:(.text+0x143): undefined reference to `mat_free'
obj/matsolve.o: In function `mat_lsolve':
matsolve.c:(.text+0x562): undefined reference to `mat_copy'
matsolve.c:(.text+0x570): undefined reference to `mat_copy'
matsolve.c:(.text+0x58e): undefined reference to `mat_creat'
matsolve.c:(.text+0x5ac): undefined reference to `mat_creat'
matsolve.c:(.text+0x5f4): undefined reference to `mat_free'
matsolve.c:(.text+0x5ff): undefined reference to `mat_free'
matsolve.c:(.text+0x60a): undefined reference to `mat_free'
obj/matdet.o:matdet.c:(.text+0x1b): undefined reference to `_mat_submat'
obj/matdet.o:matdet.c:(.text+0xff): undefined reference to `_mat_lu'
obj/matsubx.o: In function `mat_submat':
matsubx.c:(.text+0x2d): undefined reference to `mat_creat'
obj/matconvert.o: In function `toMatrix':
matconvert.c:(.text+0x1e): undefined reference to `mat_creat'
obj/predict.o: In function `predict':
predict.c:(.text+0x24): undefined reference to `sin'
predict.c:(.text+0x4a): undefined reference to `cos'
predict.c:(.text+0x6c): undefined reference to `mat_creat'
predict.c:(.text+0x104): undefined reference to `mat_creat'
predict.c:(.text+0x129): undefined reference to `cos'
predict.c:(.text+0x162): undefined reference to `sin'
predict.c:(.text+0x190): undefined reference to `sin'
predict.c:(.text+0x1bb): undefined reference to `cos'
predict.c:(.text+0x1d2): undefined reference to `mat_tran'
predict.c:(.text+0x1e6): undefined reference to `mat_mul'
predict.c:(.text+0x1f2): undefined reference to `mat_mul'
predict.c:(.text+0x1ff): undefined reference to `mat_tran'
predict.c:(.text+0x213): undefined reference to `mat_mul'
predict.c:(.text+0x21f): undefined reference to `mat_mul'
predict.c:(.text+0x22b): undefined reference to `mat_add'
predict.c:(.text+0x24f): undefined reference to `sin'
predict.c:(.text+0x278): undefined reference to `pi_to_pi'
predict.c:(.text+0x2bd): undefined reference to `puts'
predict.c:(.text+0x2c8): undefined reference to `mat_dump'
predict.c:(.text+0x2d4): undefined reference to `puts'
predict.c:(.text+0x2df): undefined reference to `mat_dump'
obj/vehicle_model.o: In function `vehicle_model':
vehicle_model.c:(.text+0x26): undefined reference to `puts'
vehicle_model.c:(.text+0x75): undefined reference to `printf'
vehicle_model.c:(.text+0xcb): undefined reference to `cos'
vehicle_model.c:(.text+0x123): undefined reference to `sin'
vehicle_model.c:(.text+0x169): undefined reference to `sin'
vehicle_model.c:(.text+0x1a8): undefined reference to `pi_to_pi'
vehicle_model.c:(.text+0x1ed): undefined reference to `__stack_chk_fail'
collect2: ld returned 1 exit status
mingw32-make: *** [ekfslam] Error 1

thank you.Ü

On Fri, Nov 21, 2008 at 9:44 PM, JonY <[hidden email]> wrote:
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
_______________________________________________
On 11/21/2008 17:04, Carl Immanuel Manalo wrote:
> hi. i posted before about trying to include my own header files in a C code.
> my problem with it is that it couldn't find the header file i'm trying to
> include
>
> #include "matrix.h"
>
> i got the code from one of my groupmates who used a make file to compile it.
> it works perfectly for her, but it doesn't work for me. even if i placed the
> matrix.h file in the same folder as the source files, it still doesn't work.
> someone suggested putting the path of the include folder into the make file.
> since i'm new to make files, i don't know where to put it. what i tried
> though is put the path in this line
>
> IDIR =../include
>
> which i'm assuming is the path to the include folder. it didn't work. below
> is the complete make file. perhaps there is something there you guys could
> see but i don't.Ü thank you.Ü
>
> IDIR =../include
> CC=gcc
> CFLAGS=-I$(IDIR)
>
> ODIR=obj
> LDIR =../lib
>
> _DEPS = matrix.h configfile.h
> DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
>
> _OBJ = matcreat.o matdump.o materr.o matadd.o matsub.o \
> matmul.o matinv.o matsolve.o mattran.o matdet.o mattoepz.o matdurbn.o
> matsubx.o \
> matconvert.o matsmul.o\
> add_control_noise.o compute_steering.o get_observations.o mathfunc.o
> observe_heading.o \
> pi_to_pi.o predict.o add_observation_noise.o\
> vehicle_model.o
> OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
>
> $(ODIR)/%.o: %.c $(DEPS)
>      $(CC) -c -o $@ $<  $(CFLAGS)
>
> ekfslam: ekfslam.c $(OBJ)
>      gcc -o $@ $^ $(CFLAGS) -lm
>
> .PHONY: clean
>
> clean:
>      rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
>
>

Hi,
Its possible that it is make that can't find it instead of gcc. You can
try removing matrix.h from the _DEPS line.

What was the error message anyway?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: including own header files

JonY-2
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
_______________________________________________
On 11/22/2008 18:37, Carl Immanuel Manalo wrote:

>
> hello again here is the compile output when i type "mingw32-make" in the
> command line.Ü oh. i also forget to mention that my classmate was using the
> gcc with ubuntu.
>
> gcc -o ekfslam ekfslam.c obj/matcreat.o obj/matdump.o obj/materr.o
> obj/matadd.o
> obj/matsub.o obj/matmul.o obj/matinv.o obj/matsolve.o obj/mattran.o
> obj/matdet.
>   obj/mattoepz.o obj/matdurbn.o obj/matsubx.o obj/matconvert.o obj/matsmul.o
> obj
> add_control_noise.o obj/compute_steering.o obj/mathfunc.o obj/pi_to_pi.o
> obj/pr
> dict.o obj/vehicle_model.o -I../include -lm
> C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0xab): undefined
> ref
> rence to `_toMatrix'
> C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0xbc): undefined
> ref
> rence to `_toMatrix'
> C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0x1b4): undefined
> re
> erence to `_vehicle_model'
> C:\DOCUME~1\Carl\LOCALS~1\Temp/ccpno8pZ.o:ekfslam.c:(.text+0x26d): undefined
> re
> erence to `_predict'
> obj/matinv.o: In function `mat_inv':
> matinv.c:(.text+0x19): undefined reference to `mat_copy'
> matinv.c:(.text+0x37): undefined reference to `mat_creat'
> matinv.c:(.text+0x54): undefined reference to `mat_creat'
> matinv.c:(.text+0x72): undefined reference to `mat_creat'
> matinv.c:(.text+0x97): undefined reference to `mat_free'
> matinv.c:(.text+0xa2): undefined reference to `mat_free'
> matinv.c:(.text+0xad): undefined reference to `mat_free'
> matinv.c:(.text+0xb8): undefined reference to `mat_free'
> matinv.c:(.text+0xe0): undefined reference to `mat_fill'
> matinv.c:(.text+0x12d): undefined reference to `mat_free'
> matinv.c:(.text+0x138): undefined reference to `mat_free'
> matinv.c:(.text+0x143): undefined reference to `mat_free'
> obj/matsolve.o: In function `mat_lsolve':
> matsolve.c:(.text+0x562): undefined reference to `mat_copy'
> matsolve.c:(.text+0x570): undefined reference to `mat_copy'
> matsolve.c:(.text+0x58e): undefined reference to `mat_creat'
> matsolve.c:(.text+0x5ac): undefined reference to `mat_creat'
> matsolve.c:(.text+0x5f4): undefined reference to `mat_free'
> matsolve.c:(.text+0x5ff): undefined reference to `mat_free'
> matsolve.c:(.text+0x60a): undefined reference to `mat_free'
> obj/matdet.o:matdet.c:(.text+0x1b): undefined reference to `_mat_submat'
> obj/matdet.o:matdet.c:(.text+0xff): undefined reference to `_mat_lu'
> obj/matsubx.o: In function `mat_submat':
> matsubx.c:(.text+0x2d): undefined reference to `mat_creat'
> obj/matconvert.o: In function `toMatrix':
> matconvert.c:(.text+0x1e): undefined reference to `mat_creat'
> obj/predict.o: In function `predict':
> predict.c:(.text+0x24): undefined reference to `sin'
> predict.c:(.text+0x4a): undefined reference to `cos'
> predict.c:(.text+0x6c): undefined reference to `mat_creat'
> predict.c:(.text+0x104): undefined reference to `mat_creat'
> predict.c:(.text+0x129): undefined reference to `cos'
> predict.c:(.text+0x162): undefined reference to `sin'
> predict.c:(.text+0x190): undefined reference to `sin'
> predict.c:(.text+0x1bb): undefined reference to `cos'
> predict.c:(.text+0x1d2): undefined reference to `mat_tran'
> predict.c:(.text+0x1e6): undefined reference to `mat_mul'
> predict.c:(.text+0x1f2): undefined reference to `mat_mul'
> predict.c:(.text+0x1ff): undefined reference to `mat_tran'
> predict.c:(.text+0x213): undefined reference to `mat_mul'
> predict.c:(.text+0x21f): undefined reference to `mat_mul'
> predict.c:(.text+0x22b): undefined reference to `mat_add'
> predict.c:(.text+0x24f): undefined reference to `sin'
> predict.c:(.text+0x278): undefined reference to `pi_to_pi'
> predict.c:(.text+0x2bd): undefined reference to `puts'
> predict.c:(.text+0x2c8): undefined reference to `mat_dump'
> predict.c:(.text+0x2d4): undefined reference to `puts'
> predict.c:(.text+0x2df): undefined reference to `mat_dump'
> obj/vehicle_model.o: In function `vehicle_model':
> vehicle_model.c:(.text+0x26): undefined reference to `puts'
> vehicle_model.c:(.text+0x75): undefined reference to `printf'
> vehicle_model.c:(.text+0xcb): undefined reference to `cos'
> vehicle_model.c:(.text+0x123): undefined reference to `sin'
> vehicle_model.c:(.text+0x169): undefined reference to `sin'
> vehicle_model.c:(.text+0x1a8): undefined reference to `pi_to_pi'
> vehicle_model.c:(.text+0x1ed): undefined reference to `__stack_chk_fail'
> collect2: ld returned 1 exit status
> mingw32-make: *** [ekfslam] Error 1
>
> thank you.Ü
>

Hi,
Please DO NOT top post.

Something is very wrong here.

Undefined references to puts, printf, sin and cos? Are you sure you are
not accidentally linking to libraries compiled for other platforms?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: including own header files

Carl Immanuel Manalo
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
_______________________________________________

hmmm.... that is also a possibility. i will work on that. thank you.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users