MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

mathlink and gcc problem

  • To: mathgroup at
  • Subject: [mg32154] mathlink and gcc problem
  • From: Scott Beckman <scott at>
  • Date: Sat, 29 Dec 2001 18:00:34 -0500 (EST)
  • Sender: owner-wri-mathgroup at


I'm figure out the basics of linking C code into Mathematica.  

My system is RedHat Linux 7.2 with Mathematica and gcc-2.96-98

According to the introductory page at wolfram 
( I should be able to link the c 

#include "mathlink.h"
int f(int x, int y)
  return x+y;

with template file
:Function:      f
:Pattern:       f[x_Integer, y_Integer]
:Arguments:     {x, y}
:ArgumentTypes: {Integer, Integer}
:ReturnType:    Integer

to complile with the command 

mcc -o f.exe f.c

I believe that I have the libraries in the ld path and everything in 
 When I run the mcc command I receive the error:

/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function 
undefined reference to `main'
collect2: ld returned 1 exit status

This seems to be an error because I don't have a main in f.c.  If I run 

gcc f.c

I get an identical error, but if I run

gcc -c f.c 

I don't have an error because gcc stops after producing the object files 

Now that I have the object file I still cannot use

mcc -o f.exe f.o 

because I'm given the error from above

Is there a way I can use gcc with mcc to build the example file on 
wolfram's tutorial page?

Thank you,

Scott Beckman
Department of Material Science and Engineering
sbeckman at

  • Prev by Date: Re: Searching for embedded zeros in list
  • Next by Date: Install ExtendGraphics/MathLink problem
  • Previous by thread: Re: Meaning of @ ... not @@
  • Next by thread: Install ExtendGraphics/MathLink problem