Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: manc on December 06, 2007, 01:46:34 am

Title: Error in linker, please help!
Post by: manc on December 06, 2007, 01:46:34 am
Hello ever body!

I have a problema compiling a very simple program of linera algebra. I got messages like

mingw32-g++.exe    -L"C:\Archivos de programa\CodeBlocks\lib" -o C:\Progs\MetNum\SEL\Gauss\Gauss.exe .objs\gauss.o .objs\sel.o .objs\main.o         -mwindows
.objs\main.o:main.c:(.text+0xc7): undefined reference to `MkMatriz'
.objs\main.o:main.c:(.text+0xfe): undefined reference to `MkVector'
...
and other functions that really are in some of the modules.

Any idea?

Thanks!
Title: Re: Error in linker, please help!
Post by: stahta01 on December 06, 2007, 02:07:22 am
What library is it in? Or if not in a library, what object file is it in?
Did you link to that library or Object file?

Tim S
Title: Re: Error in linker, please help!
Post by: manc on December 06, 2007, 03:26:10 pm
This is a tiny project. The files are main.c, gauss.c, sel.c, and sel.h, the last one included in all .c modules.

Im using only ANSI C. It works fine in other IDEs: borland, Dev-C.

Whant to see the files? I can send them.


Miguel Angel

Title: Re: Error in linker, please help!
Post by: alchemist on December 06, 2007, 04:47:48 pm
and where is the .c file with the definition of MkMatriz and MkVector ?
Title: Re: Error in linker, please help!
Post by: manc on December 06, 2007, 05:14:10 pm
MkMatriz and MkVector are defined in sel.c and declared in sel.

Miguel
Title: Re: Error in linker, please help!
Post by: manc on December 06, 2007, 05:28:05 pm
MkMatriz and MkVector are defined in sel.c and declared in sel.h
Title: Re: Error in linker, please help!
Post by: alchemist on December 06, 2007, 06:37:49 pm
ermm... you have C code compiled with the C++ compiler...

You have 2 alternatives :
- compile with gcc in place of g++
- surround each declaration of your C functions by

Code
#ifdef __cplusplus
extern "C" {
#endif

/* your declarations here */

#ifdef __cplusplus
}
#endif
Title: Re: Error in linker, please help!
Post by: manc on December 06, 2007, 07:02:08 pm
 :oops: Thanks, it compiles now!

Title: Re: Error in linker, please help!
Post by: alchemist on December 07, 2007, 10:05:35 am
No shame, everybody does that error. Even C++ is compatible with C, the linkage is different and you have to be careful when using C linked code with C++ ;)