Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

mathlink and gcc problem

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

Hello,

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

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

According to the introductory page at wolfram 
(http://library.wolfram.com/howtos/ccode/) I should be able to link the c 
program

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

with template file

f.tm:
:Begin:
:Function:      f
:Pattern:       f[x_Integer, y_Integer]
:Arguments:     {x, y}
:ArgumentTypes: {Integer, Integer}
:ReturnType:    Integer
:End:

to complile with the command 

mcc -o f.exe f.tm f.c

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

/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function 
`_start':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): 
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 
f.o.  

Now that I have the object file I still cannot use

mcc -o f.exe f.tm 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


Scott Beckman
U.C.Berkeley
Department of Material Science and Engineering
sbeckman at uclink.berkeley.edu



  • 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