How to create MS VC++ project for UMFPACK

971 views
Skip to first unread message

Volodymyr Kachurovskyi

unread,
May 28, 2008, 10:25:32 AM5/28/08
to matrixprogramming
Recently I needed to compile UMFPACK and link it to MS VC++ project.
While the way described by Evgenii Rudnyi here http://matrixprogramming.com/UMFPACK/
works pretty well for x86 platform I have not managed to do it the
same way for x64.
Quick googling suggests there's no 64-bit gcc under Cygwin.
Building x86_64 cross compiler under Cygwin does not seem feasible as
well (at least for me).

So, I decided to use MSVC compiler to build UMFPACK for x64 platform.
There are three options here:
1) Use MSVC compiler under Cygwin. The main disadvantage here is that
we do not result with MSVC project and we still need to use Cygwin to
build the package.

2) Create MS VC++ Makefile Project. MS VC++ have its own makefiles
that can be used instead of UNIX makefiles. Personally, I know nothing
about MS VC++ Makefile Projects.

3) Wrap the UMFPACK source. The problem is that we can not simply add
all *.h and *.c files to MS VC++ project and compile them. That is
because UMFPACK is written on C (not C++) and has not C++ templates.
Templates are emulated through macroses in the following way: some
functions that need to be templated have their signature and body
depending on pre-processor macroses defined. The same c-file is
compiled into different obj-files by defining different macroses. In
the original makefile this looks like the following:
$(C) -DDINT -c ../Source/umf_analyze.c -o umf_i_analyze.o
$(C) -DDLONG -c ../Source/umf_analyze.c -o umf_l_analyze.o
So, what can be done is the following: additional c-file is created
for each such a line in the makefile. These c-files simply define
necessary macroses (like DINT or DLONG above) and include (#include)
original c-file (e.g. umf_analyze.c above).

Example of such "wrapping" c-file is below:
#include "..\..\MSettings.h"
#define DINT
#include "..\Original\umf_analyze.c"

MSettings.h file also included in all wrapping c-files is needed for
defining common macroses (like NBLAS) - instead of options previously
defined in UFconfig.mk

Regards,
Volodymyr Kachurovskyi.

Evgenii Rudnyi

unread,
May 29, 2008, 2:51:38 PM5/29/08
to matrixpr...@googlegroups.com, Volodymyr.K...@gmail.com
> Recently I needed to compile UMFPACK and link it to MS VC++ project.
> While the way described by Evgenii Rudnyi here http://matrixprogramming.com/UMFPACK/
> works pretty well for x86 platform I have not managed to do it the
> same way for x64.
> Quick googling suggests there's no 64-bit gcc under Cygwin.

This is correct.

> Building x86_64 cross compiler under Cygwin does not seem feasible as
> well (at least for me).

I agree, this would be too complicated.

> So, I decided to use MSVC compiler to build UMFPACK for x64 platform.
> There are three options here:
> 1) Use MSVC compiler under Cygwin. The main disadvantage here is that
> we do not result with MSVC project and we still need to use Cygwin to
> build the package.

This is an option that I am trying to follow now, as I know and like GNU
Make. This way, in my view, the changes will be minimal. I will prepare
an example for UMPFACK soon.

> 2) Create MS VC++ Makefile Project. MS VC++ have its own makefiles
> that can be used instead of UNIX makefiles. Personally, I know nothing
> about MS VC++ Makefile Projects.

Make from MS VC is called nmake. It will require more editing, as
makefiles between GNU Make and nmake are not compatible. Well, they look
similar but there are many differences as well. I am personally not
going to learn nmake, as I use cygwin anyway - I find the capabilities
of cmd of pretty limited use.

> 3) Wrap the UMFPACK source. The problem is that we can not simply add
> all *.h and *.c files to MS VC++ project and compile them. That is
> because UMFPACK is written on C (not C++) and has not C++ templates.
> Templates are emulated through macroses in the following way: some
> functions that need to be templated have their signature and body
> depending on pre-processor macroses defined. The same c-file is
> compiled into different obj-files by defining different macroses. In
> the original makefile this looks like the following:
> $(C) -DDINT -c ../Source/umf_analyze.c -o umf_i_analyze.o
> $(C) -DDLONG -c ../Source/umf_analyze.c -o umf_l_analyze.o
> So, what can be done is the following: additional c-file is created
> for each such a line in the makefile. These c-files simply define
> necessary macroses (like DINT or DLONG above) and include (#include)
> original c-file (e.g. umf_analyze.c above).
>
> Example of such "wrapping" c-file is below:
> #include "..\..\MSettings.h"
> #define DINT
> #include "..\Original\umf_analyze.c"
>
> MSettings.h file also included in all wrapping c-files is needed for
> defining common macroses (like NBLAS) - instead of options previously
> defined in UFconfig.mk

This is a feasible solution. Thanks for describing it.

Still, I would say, it requires more work. Imaging that you will need to
compile the next version of UMPFACK - then this process should be repeated.

Best wishes,

Evgenii

Evgenii Rudnyi

unread,
May 31, 2008, 2:23:49 PM5/31/08
to matrixpr...@googlegroups.com
> This is an option that I am trying to follow now, as I know and like GNU
> Make. This way, in my view, the changes will be minimal. I will prepare
> an example for UMPFACK soon.

I have made the changes and documented them at

Compiling UMFPACK with Microsoft Visual C
http://matrixprogramming.com/UMFPACK/UMPFACK_VC.html

Please have a look. In my view, it should work for 64-bit without changes.

Rishi

unread,
Feb 6, 2012, 3:47:25 PM2/6/12
to matrixpr...@googlegroups.com
Hi Evgenii,

   I am trying to find your link above - but it does not seem to be working. Can you please point me to the correct link ?

Thanks,

Kind regards,
Rishi

Evgenii Rudnyi

unread,
Feb 7, 2012, 1:37:46 PM2/7/12
to matrixpr...@googlegroups.com
On 06.02.2012 21:47 Rishi said the following:

It should be by http://matrixprogramming.com

I should confess that I cannot access it right now. You also cannot open it?

Evgenii


Rishi

unread,
Feb 7, 2012, 5:48:01 PM2/7/12
to matrixpr...@googlegroups.com
Thanks for your reply. I can open that. I want to use SuiteSparse / UMFPACK for my application in Visual C++.


Here is what I get when I run make in Cygwin or MinGW

LINK : fatal error LNK1181: cannot open input file 'rv'
make[2]: *** [libumfpack.lib] Error 157
make[2]: Leaving directory `/home/R.Amrit/SuiteSparse - Copy/UMFPACK/Lib'
make[1]: *** [../Lib/libumfpack.lib] Error 2
make[1]: Leaving directory `/home/R.Amrit/SuiteSparse - Copy/UMFPACK/Demo'
make: *** [all] Error 2

Any clues ? 

Thanks a lot.

Evgenii Rudnyi

unread,
Feb 11, 2012, 4:30:44 AM2/11/12
to matrixpr...@googlegroups.com
On 07.02.2012 23:48 Rishi said the following:

Could you please write the command that produces this error?

Reply all
Reply to author
Forward
0 new messages