Author Topic: Error in linker, please help!  (Read 4134 times)

Offline manc

  • Single posting newcomer
  • *
  • Posts: 5
Error in linker, please help!
« 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!

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7604
    • My Best Post
Re: Error in linker, please help!
« Reply #1 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
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline manc

  • Single posting newcomer
  • *
  • Posts: 5
Re: Error in linker, please help!
« Reply #2 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


Offline alchemist

  • Multiple posting newcomer
  • *
  • Posts: 38
    • My Blog
Re: Error in linker, please help!
« Reply #3 on: December 06, 2007, 04:47:48 pm »
and where is the .c file with the definition of MkMatriz and MkVector ?
Kind Regards,
Xavier Miller.
http://xaviermiller.be

Offline manc

  • Single posting newcomer
  • *
  • Posts: 5
Re: Error in linker, please help!
« Reply #4 on: December 06, 2007, 05:14:10 pm »
MkMatriz and MkVector are defined in sel.c and declared in sel.

Miguel

Offline manc

  • Single posting newcomer
  • *
  • Posts: 5
Re: Error in linker, please help!
« Reply #5 on: December 06, 2007, 05:28:05 pm »
MkMatriz and MkVector are defined in sel.c and declared in sel.h

Offline alchemist

  • Multiple posting newcomer
  • *
  • Posts: 38
    • My Blog
Re: Error in linker, please help!
« Reply #6 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
Kind Regards,
Xavier Miller.
http://xaviermiller.be

Offline manc

  • Single posting newcomer
  • *
  • Posts: 5
Re: Error in linker, please help!
« Reply #7 on: December 06, 2007, 07:02:08 pm »
 :oops: Thanks, it compiles now!


Offline alchemist

  • Multiple posting newcomer
  • *
  • Posts: 38
    • My Blog
Re: Error in linker, please help!
« Reply #8 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++ ;)
Kind Regards,
Xavier Miller.
http://xaviermiller.be