Message Boards Message Boards

0
|
10176 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

ExportString and CreateExecutable

Posted 9 years ago

Re v10.2 under Windows 8.1.

What causes the two error messages below? One says to convert code to DOS format -- but doesn't Mathematica pump out C99-standard code? Is this fix as simple as specifying some option to CreateExecutable? Notice that the ExportString output is atch'd (there's a renegade leading quote).

Maybe there's a known problem with the installed C compiler. Maybe the first message causes the other. No doubt user-error is the culprit but I don't know.

Thanks.

Bruce


The code is:

Needs@"CCompilerDriver`";
CCompilers[]
g=Compile[{x},x^2];
cCode=ExportString[g,"C"]; (* code is atch'd as CCode.txt *)
CreateExecutable[cCode,"mine"]

CCompilers[] above returns:

{{"Name" -> "Visual Studio", 
  "Compiler" -> 
   CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
  "CompilerInstallation" -> 
   "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0", 
  "CompilerName" -> Automatic}}

The error messages are

CreateExecutable::cmperr: Compile error: C:\Users\Bruce\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Wind\[Ellipsis] format detected: please convert the source file to either DOS or UNIX format >>

CreateExecutable::cmperr: Compile error: C:\Users\Bruce\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Wind\[Ellipsis]  file: 'm-dde41816-6467-4e82-b364-babb0f35cfd0.h': No such file or directory >>
Attachments:
POSTED BY: Bruce Colletti
6 Replies
POSTED BY: Ilian Gachevski
Posted 9 years ago

For those who are interested, I've started the new thread titled CreateExecutable that is rooted in the one here.

POSTED BY: Bruce Colletti

It must be Apple here's Dos

Needs["CCompilerDriver"]
CCompilers[]
g=Compile[{x},x^2];
cCode=ExportString [g,"C"];    
CreateExecutable[cCode,"mine"]

This gives the same output without the errors in dos

Posted 9 years ago

Thank you for the reply, Melvin. I've entered your code but it seems to be the same as before -- the same errors arise.

But it worked for you and so that suggests that your setup differs from mine. What is your OS and C Compiler?

POSTED BY: Bruce Colletti

The Mac line endings shouldn't be there, it sounds like a bug.

The second error message is expected, because there is no header (.h) file generated. Also, to make a standalone executable you would need to supply an appropriate main() function and link to appropriate runtime libraries. See the following tutorial for a couple of examples:

http://reference.wolfram.com/language/CCodeGenerator/tutorial/Overview.html

POSTED BY: Ilian Gachevski
Posted 9 years ago

The first error message "...convert to DOS ..." is tied to MS error C4335 that appeared when I re-ran the code -- see https://msdn.microsoft.com/en-us/library/aad7fash.aspx

The string ExportString[g,"C"] had embedded '\r' Mac characters (I'm running Windows) that were struck by:

sourceCode = 
  Characters@StringReplace[ExportString[g, "C"], "\r" -> ""] // StringJoin;

Now when I run:

CreateExecutable[sourceCode, "xyz", "TargetDirectory" -> "c://temp"]

only the second error message remains -- it's tied to error C1083; see https://msdn.microsoft.com/en-us/library/et4zwx34.aspx

Any ideas on how to avoid this error?

POSTED BY: Bruce Colletti
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract