Re: Baby mathlink question.
- To: mathgroup at smc.vnet.net
- Subject: [mg15395] Re: Baby mathlink question.
- From: kevinl (Kevin Leuthold)
- Date: Tue, 12 Jan 1999 03:14:56 -0500
- Organization: Wolfram Research, Inc.
- References: <774ijd$3vg@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John, On Solaris, as opposed to most other Unix operating systems, you need to link against two other libraries, libnsl and libsocket. mcc should automatically do this for you, but it doesn't (this will be fixed in the next major version of Mathematica). So, change mcc -o sample2 -I/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions sample2.tm mcc -o sample2 -I/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions sample2.tm -lnsl -lsocket Kevin Leuthold MathLink Group Wolfram Research John L Weatherwax <wax at mit.edu> writes: >Hello, > I am new at this and am having trouble getting MathLink to work for the >first time. I am trying the example in the Mathematica book. I have >the following two files, sample2.tm and sample2.c >sample2.tm... >:Begin: >:Function: f >:Pattern: f[x_Integer, y_Integer] >:Arguments: {x, y} >:ArgumentTypes: {Integer, Integer} >:ReturnType: Integer >:End: >sample2.c... >#include "mathlink.h" >int f(int x, int y) { > return x+y; >} >int main(int argc, char *argv[]) { > return MLMain(argc, argv); >} >I am running on a unix platform and I type >mcc -o sample2 >-I/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions >sample2.tm >and I get back... >Undefined first referenced > symbol in file socket >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >recv >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >f sample2.tm.o gethostbyname >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >accept >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >send >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >bind >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >setsockopt >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >gethostbyaddr >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >getsockname >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >main /opt/SUNWspro/SC4.0/lib/crt1.o >listen >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >connect >/usr/local/mathematica3.0/AddOns/MathLink/DevelopersKits/Solaris/CompilerAdditions/libML.a(sockport.o) >ld: fatal: Symbol referencing errors. No output written to sample2 >I am sure that there is a one line answer to why this is not working. I >would greatly appreciate any help, anyone with more experience (or >brains) than myself could give. > Thanks, and sorry for my ignorance, > John Weatherwax