Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiling on windows #3

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

compiling on windows #3

wants to merge 15 commits into from

Conversation

rhambach
Copy link

@rhambach rhambach commented Mar 7, 2016

Dear ahbarnett,

thanks a lot for your demo files for MWrap. As I have to work with Windows, I added some Makefiles for NMake to compile Mwap-0.33.3, the examples of Mwrap, as well es your demo files for c and c2domp. They worked for me (Windows Server 2012), but I guess one should cross-check them on a different Windows system and test the Linux and Mac version again, as I had to make some changes in the code. But maybe it is already a good starting point for adding Makefiles for Windows.

Best, RHambach.

rhambach and others added 15 commits November 11, 2015 19:25
- had to add "return 0;" to yyerror function
Note: C++ compiler was used for all files (including lexwin.yy.cc)
references to external symbols had to be adapted accordingly
- compiled with SDK7.1 for 32bit and 64bit systems
- checked with matlab R2014b 32bit and 64bit
- all examples work except
- ERROR: eventq - handle fails in Matlab
- WARNING: zlib not found
…t->int

- add Makefiles and make.win.inc
- re-add lib.cc (acidentally removed)
- switch to C++ compiler as C99 complex numbers are not available in SDK7.1
- use MEX compiler also for library (thus we are sure to use the same options)
- ERROR: 'myfunc' identifier not found
- WARNING: conversion from 'size_t' to 'int' (we do not use mwSize,mwIndex types)
- we have to declare the external library function 'myfunc' in the *.mw file
  by including a corresponding *.hh file
- -largeArrayDims was not used so far -> origin of earlier warnings
- mwSize is a typedef, #ifndef mwSize will always evaluate to true
  and mwSize is thus redefined as int
- correct this bug by checking for MWSIZE_MAX
  (from http://www.mathworks.com/matlabcentral/answers/59490-data-type-errors-in-tmwtypes-h-while-compiling-with-mex )
@ahbarnett
Copy link
Owner

Hello Ralf,
Thanks for doing this - I look forward to merging your changes! However, there's some stuff I'd love us to chat about first, so that the repo preserves some of my original goals:

  1. I'd really like to keep your new C++ examples separate from the C examples. This keeps the latter as simple as possible. Eg if you want to mwrap an existing scientific library, you won't want to be introducing mwSize objects into the library source; rather you'd want to leave it in pure C if it came that way. Likewise for the C++ complex type (which I don't use). Would you be able to create cpp and cpp2domp directories for your examples? (Now, it could be that windows breaks unless you use mwSize, C++ complex, etc ... let me know if true and we have to rethink).

  2. I haven't had time to test it out yet (pull requests are new for me). Maybe I'll wait until we decide on point 1?

  3. You have made a lot of changes to MWrap itself (way beyond what I understand). These should be also sent to Bindel, the author, for his consideration. I am happy to keep this locally-hacked MWrap here, as long as we state that it's been changed to work with windows (right? all those changes were to get that working?), but if Bindel ever updates (he probably won't since he hasn't for a few years), we'll be stuck.

  4. This is minor, but, the trailing double-spaces in the README.md are part of markdown and cause a CR (carriage return) iie new line. So I would reinsert them.

What do you think?
Best, Alex

@rhambach
Copy link
Author

Dear Alex,

I would like to briefly answer your comments/questions in random order

  1. I guess it is worth checking first, if I accidentally broke compilation on Linux/Mac by some changes. If it is not easily repairable, one can probably save the time for merging. I am sorry that I cannot perform these tests myself.

  2. I actually introduced only very few changes in MWrap. Most of the highlighted differences are due to the automatically generated files mwrap.cc and lexwin.yy.cc as I have used a newer version of Flex/Bison (v.2.7 instead of v2.5, all changes are included in commit e9b5bb4). The actual source files mwrap.y and mwrap.l have only very few changes. I summarized the actual changes below (see description of commits):

  • a5efd1a compiler complains about missing return 0; in yyerror
  • b3cdb8c switched to C++ compiler, renaming .c->.cc, adapt references to external symbols (EXTERN_C)
  • b8a70b9 correct small bug in MWrap in typedefs for mwSize, ...
  1. Switching from C to C++ was necessary for Windows, as the Microsoft Visual Studio C compiler does not support complex numbers at all (see link). I did not want to mix C and C++ compilation, so I switched completely. Pure 'C' examples with complex numbers thus would not work in Windows. The renaming of the files to .cc is convenient on Windows, as the compiler does not recognize .C or .cpp, but probably one should revert this as it is quit unusual under Linux/Mac.

I did not completely understand your comment on mwSize "objects". As far as I understand, mwSize and co are just typedefs for int or size_t and should be used both in C and C++ (see link).

  1. I am sorry. I did not pay attention to the white-spaces at the beginning and probably forgot to restore all of them.

Best regards, Ralf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants