Jump to content
Geochemist's Workbench Support Forum

Pipe


ilya

Recommended Posts

Hello, I am currently working on a project that requires MATLAB to communicate with Geochemist's Workbench. I found the sample code provided within the documentation and tried compiling it as a MATLAB MEX file only to receive many errors such as:

 

lcc preprocessor error: pipe.cpp:4 Could not find include file <iostream>

lcc preprocessor error: pipe.cpp:5 Could not find include file <string>

Error pipe.cpp: .\RC_helper.cpp: 26 syntax error; found `stdiopipe' expecting `;'

Error pipe.cpp: .\RC_helper.cpp: 26 syntax error; found `(' expecting `)'

Error pipe.cpp: .\RC_helper.cpp: 26 skipping `(' "unnamedpipe"

Error pipe.cpp: .\RC_helper.cpp: 26 extraneous old-style parameter list

Error pipe.cpp: .\RC_helper.cpp: 26 syntax error; found `)' expecting `;'

Error pipe.cpp: .\RC_helper.cpp: 26 skipping `)'

Error pipe.cpp: .\RC_helper.cpp: 30 syntax error; found `&' expecting `)'

Error pipe.cpp: .\RC_helper.cpp: 30 skipping `&' `pipe'

Error pipe.cpp: .\RC_helper.cpp: 32 undeclared identifier `pipe'

Error pipe.cpp: .\RC_helper.cpp: 32 left operand of . has incompatible type `int'

Error pipe.cpp: .\RC_helper.cpp: 32 type error: pointer expected

Warning pipe.cpp: .\RC_helper.cpp: 32 possible usage of pipe before definition

Error pipe.cpp: .\RC_helper.cpp: 36 redefinition of `Clear' previously defined at .\RC_helper.cpp 30

Error pipe.cpp: .\RC_helper.cpp: 36 redeclaration of `Clear' previously declared at .\RC_helper.cpp 30

Error pipe.cpp: .\RC_helper.cpp: 37 too many arguments to `Clear'

Error pipe.cpp: .\RC_helper.cpp: 38 asm: label _Clear: redefined

Error pipe.cpp: .\RC_helper.cpp: 43 syntax error; found `&' expecting `)'

Error pipe.cpp: .\RC_helper.cpp: 43 skipping `&' `pipe'

Error pipe.cpp: .\RC_helper.cpp: 45 undeclared identifier `DWORD'

Warning pipe.cpp: .\RC_helper.cpp: 45 Statement has no effect

Error pipe.cpp: .\RC_helper.cpp: 45 too many errors

 

I was wondering if you know if it's something I'm doing wrong or if the provided code itself does not function. If so, who do you suggest I contact to aid in the process of writing a pipe between MATLAB and GWB?

Thank you.

Link to comment
Share on other sites

Hello:

 

I recommend checking your syntax- as the error messages suggest,this is likely cause by missing a semicolon somewhere. If this occurs in one line of code, all of the other lines of code can become uninterpretable.

 

I hope that helps,

 

Tom Meuzelaar

RockWare,Inc.

Link to comment
Share on other sites

Thank you for your quick response. The problem is that all of the errors appear to be in the RC_helper.cpp/RC_helper.h (whichever I try) file provided with the program. So it appears that the syntax within the library file that came with the program is incorrect...

Have others used the RC_helper.cpp/RC_helper.h file successfully?

 

I also tried compiling the unedited RC_example2.cpp and I got:

 

Error RC_example2.cpp: .\RC_helper.h: 9 syntax error; found `CharArray' expecting `;'

Error RC_example2.cpp: .\RC_helper.h: 9 syntax error; found `{' expecting `;'

Error RC_example2.cpp: .\RC_helper.h: 9 skipping `{'

Error RC_example2.cpp: .\RC_helper.h: 10 syntax error; found `:' expecting `;'

Error RC_example2.cpp: .\RC_helper.h: 10 skipping `:'

Error RC_example2.cpp: .\RC_helper.h: 11 redeclaration of `CharArray' previously declared at .\RC_helper.h 9

Error RC_example2.cpp: .\RC_helper.h: 11 syntax error; found `:' expecting `;'

Error RC_example2.cpp: .\RC_helper.h: 11 skipping `:'

Error RC_example2.cpp: .\RC_helper.h: 11 syntax error; found `1024' expecting `)'

Error RC_example2.cpp: .\RC_helper.h: 11 skipping `1024'

Error RC_example2.cpp: .\RC_helper.h: 12 undeclared identifier `m_buff'

Error RC_example2.cpp: .\RC_helper.h: 12 type error in argument 1 to `malloc'; found `pointer to int function(void)' expected `unsigned int'

Error RC_example2.cpp: .\RC_helper.h: 12 operands of = have illegal types `int' and `pointer to char'

Error RC_example2.cpp: .\RC_helper.h: 13 undeclared identifier `m_size'

Error RC_example2.cpp: .\RC_helper.h: 13 operands of = have illegal types `int' and `pointer to int function(void)'

Error RC_example2.cpp: .\RC_helper.h: 13 type error: pointer expected

Warning RC_example2.cpp: .\RC_helper.h: 14 missing return value

Error RC_example2.cpp: .\RC_helper.h: 15 unrecognized declaration

Error RC_example2.cpp: .\RC_helper.h: 15 undeclared identifier `m_buff'

Error RC_example2.cpp: .\RC_helper.h: 15 type error in argument 1 to `free'; found `int' expected `pointer to void'

Warning RC_example2.cpp: .\RC_helper.h: 15 possible usage of m_buff before definition

Warning RC_example2.cpp: .\RC_helper.h: 15 missing return value

Error RC_example2.cpp: .\RC_helper.h: 16 undeclared identifier `m_size'

Warning RC_example2.cpp: .\RC_helper.h: 16 possible usage of m_size before definition

Error RC_example2.cpp: .\RC_helper.h: 18 too many errors

Link to comment
Share on other sites

Hello:

 

Yes, I've used the RC_helper.h and RC_helper.cpp source files without too much trouble using Visual Studio. I had to adjust a few settings in the default setup for VS, including:

 

1. In project settings, remove explicit use of the Unicode character set.

 

2. Turn off use of precompiled headers

 

However, these settings are specific to Visual Studio, so they may or may not help you. I can tell you that there is nothing wrong with the RC_helper.h and RC_helper.cpp code, and that your problem is probably somewhere in the configuration of the application you are using for code development.

 

Unfortunately, my response time will be much slower after this, as I am about to step out for a 4-day holiday weekend.

 

Regards,

 

Tom Meuzelaar

RockWare, Inc.

Link to comment
Share on other sites

  • 9 months later...

Hello Tom,

I am also working on a project that requires communication between MATLAB and Geochemist's Workbench.

I use Visual C++ as well, and on top on the fact that I couldn't "remove explicit use of the Unicode character set", I get different errors resembling this one:

error C2440: 'initializing' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'char *'

 

Would you be able to help me to use these pipe source files properly?

I am going to need them for the next 5 month of my project...

 

Thank you in advance and have a good afternoon,

 

Skyboarder

Link to comment
Share on other sites

I apologize for the vague message I sent earlier, I need to precise that I tried to add some arguments to the main function (mass, time_step, temp) for them to be sent to GWB via this pipe program. Hence I get this error

error C2440: 'initializing' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'char *'
when I try to insert them in a line of the scripts sent through the pipe :
"time begin = 0 seconds, end = " + time_step + " seconds"

Do you know any trick that I could use for that to be possible?

Thank you

 

Skyboarder

Link to comment
Share on other sites

Hi Skyboarder,

 

I'm not sure without more information, but it sounds like you probably need to use the c_str() function on the time_step variable.

 

"time begin = 0 seconds, end = " + time_step.c_str() + " seconds"

 

If that doesn't work, please provide more information about what type of variable time_step is.

 

Hope this helps.

~Dan Saalfeld

Link to comment
Share on other sites

Indeed, the expression time_step here is a string, sorry about that (Maybe a string concatenation would work?)

Here is the beginning of the code, that you might find useful to see :

/* This program works as a pipe between Geochemist's Workbench and MATLAB */

#include "RC_helper.h"
#include <iostream>
#include <string>
// #include <stdio.h>
using namespace std;

//void pipe(string &, string &, string &);

void main(string &mass_W, string &time_step, string &temp)
{

char* script1[] = 
{
  "reset",
  //"time begin = 0 seconds, end = " + time_step + " seconds",
  //"T = " + temp + " K",
  "SiO2(aq) = 1 umolal",
  "react 5000 g Quartz",
  "kinetic Quartz rate_con = 2.e-15 surface = 1000",
  "go",
  ""
};

 

Thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...