Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Mathlink and C/C++

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65841] Re: [mg65737] Mathlink and C/C++
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Tue, 18 Apr 2006 06:56:37 -0400 (EDT)
  • Reply-to: jfultz at wolfram.com
  • Sender: owner-wri-mathgroup at wolfram.com

Visual C++, by default, chooses to compile any file with the .cpp extension 
with the C++ compiler.  C++ object files don't link with C files without a 
little magic.  Possible solutions:

* Rename the file to a .c file (assuming it really is C and not C++)

* Change the extern declaration to extern "C", or simply wrap
  extern "C" around the entire header file.  E.g.,

#ifndef myheader_h_
#define myheader_h_ 1

extern "C" {

extern void myfunc(void);
extern void myfunc2(void);

}
#endif // myheader_h_ 1

* Change the VC++ project to force the file to compile with the C compiler 
(this is the /Tp switch, I believe).

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.

On Sun, 16 Apr 2006 03:49:16 -0400 (EDT), Goyan wrote:
> [This post has been delayed due to email problems - moderator]
>
>
> Hi all,
>
> Recently I have been trying to compile a program using VC++ 6 and
> Mathlink. The source code was originally written by someone else and
> under kdevelop for Linux. The source code is in *.cpp format but
> actually it is written in C. I've written a wrapper cpp file for using
> it in Mathematica. However, when I compile it, it gives the error
> message:
>
> Wrapper.tm.obj : error LNK2001: unresolved external symbol "int __cdecl
> myProgram(double *,long,double *,long,int,int,double,double)"
> (?myProgram@@YAHPANJ0JHHNN@Z)
> Debug/MyProgram.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> Has anyone had similar experience before?
>
> Thank you for your time.
>
> Regards
>
> Goyan



  • Prev by Date: Re: unable to FullSimplify
  • Next by Date: Re: How can I solve these simultaneous quadratic equations in Mathemetica?
  • Previous by thread: Mathlink and C/C++
  • Next by thread: How can I solve these simultaneous quadratic equations in Mathemetica?