Could you please describe in more detail what you have done and what
linking errors do you receive?
I have included the following lines of code in my source code:
extern "C" {
#include <taucs.h>
}
And I am calling the "taucs_linsolve" function. The linking errors I am
getting are:
1>vcf2c.lib(main.obj) : error LNK2019: unresolved external symbol
_MAIN__ referenced in function _main
1>vcf2c.lib(fmt.obj) : error LNK2001: unresolved external symbol __iob
1>vcf2c.lib(wrtfmt.obj) : error LNK2001: unresolved external symbol __iob
1>vcf2c.lib(err.obj) : error LNK2019: unresolved external symbol __iob
referenced in function _f__fatal
1>vcf2c.lib(sig_die.obj) : error LNK2001: unresolved external symbol __iob
1>libmetis.lib(util.obj) : error LNK2001: unresolved external symbol __iob
1>vcf2c.lib(s_stop.obj) : error LNK2001: unresolved external symbol __iob
1>vcf2c.lib(wref.obj) : error LNK2019: unresolved external symbol
__pctype referenced in function _wrt_E
1>vcf2c.lib(wref.obj) : error LNK2019: unresolved external symbol
___mb_cur_max referenced in function _wrt_E
When I do not ignore libcmt.lib I get the following errors:
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in
MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMT.lib(fflush.obj) : error LNK2005: _fflush already defined in
MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in
MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)"
(?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR80D.dll)
1>LIBCMT.lib(winsig.obj) : error LNK2005: _signal already defined in
MSVCRTD.lib(MSVCR80D.dll)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of
other libs; use /NODEFAULTLIB:library
1>LIBCMT.lib(unlink.obj) : error LNK2005: _remove already defined in
MSVCRTD.lib(MSVCR80D.dll)
When I ignore MSVCRTD.lib instead of libcmt.lib, I gel these errors:
1>MSVCMRTD.lib(mstartup.obj) : error LNK2020: unresolved token
(0A00008E) __native_vcclrit_reason
1>MSVCMRTD.lib(mstartup.obj) : error LNK2020: unresolved token
(0A000094) __native_startup_state
1>MSVCMRTD.lib(mstartup.obj) : error LNK2020: unresolved token
(0A0000E3) __native_startup_lock
1>MSVCMRTD.lib(mstartup.obj) : error LNK2020: unresolved token
(0A0000E4) __native_dllmain_reason
1>vcf2c.lib(main.obj) : error LNK2019: unresolved external symbol
_MAIN__ referenced in function _main
1>MSVCMRTD.lib(mstartup.obj) : error LNK2001: unresolved external symbol
___native_dllmain_reason
1>MSVCMRTD.lib(mstartup.obj) : error LNK2001: unresolved external symbol
___native_vcclrit_reason
1>MSVCMRTD.lib(mstartup.obj) : error LNK2001: unresolved external symbol
___native_startup_state
1>MSVCMRTD.lib(mstartup.obj) : error LNK2001: unresolved external symbol
___native_startup_lock
Looks like you need to recompile METIS and vcf2c under /MD. From what
you have written I do not see another option.
If I take
http://matrixprogramming.com/TAUCS/src/test_taucs.cpp
and find a way on how to compile it under /MD, will it be a solution for
your problem? If not, could you please set up an another test problem?
I will try to do it over the weekend.
So I have looked at this problem and I can suggest you some solution.
Let us start with test_taucs.cpp. When I compile it under -MD
$ cl -c -Isrc -Ibuild/win32 -EHsc -MD test_taucs.cpp
and then try to link with the libraries
$ cl test_taucs.obj libtaucs.lib libmetis.lib liblapack.lib libf77
blas.lib libcblas.lib libatlas.lib vcf2c.lib -link -LIBPATH:lib/win32
-LIBPATH:external/lib/win32
I receive the same error about the incompatibility between LIBCMT and
MSVCRT. If I tell the linker not to use LIBCMT
$ cl test_taucs.obj libtaucs.lib libmetis.lib liblapack.lib libf77
blas.lib libcblas.lib libatlas.lib vcf2c.lib -link -LIBPATH:lib/win32
-LIBPATH:external/lib/win32 -NODEFAULTLIB:LIBCMT.lib
then the linker cannot find some symbols defined in libmetis.lib and
vcf2c.lib. One can check with nm that these symbols are not in MSVCRT
indeed but they do exist in LIBCMT. As we cannot use these two libraries
together this means that we need to recompile the libraries.
It is relatively easy to recompile METIS with -MD. I have written
instructions to this end at
http://matrixprogramming.com/METIS/
Well, you need to install Cygwin to have GNU Make but I guess that this
will be faster as to modify the makefile for MS nmake.
With the optimized BLAS (liblapack.lib libf77 blas.lib libcblas.lib
libatlas.lib vcf2c.lib) the things are more complicated. There are
several options.
1) To use ATLAS compiled with gcc under cygwin. The libraries under
-mno-cygwin are compatible with MS VC. See
http://matrixprogramming.com/UMFPACK/
Sections Compiling under MinGW and Using UMFPACK with Microsoft Visual
Studio.
It could be also possible to ask the ATLAS team on how to compile it
under MS Visual C.
2) To use AMD AMCL. It is free but you have to register to download it
http://developer.amd.com/cpu/Libraries/acml/Pages/default.aspx
Be careful to choose the right AMCL version that matches your version of
the MS Visual C. I will give instructions on how to compile TAUCS to use
it with AMCL below.
3) To use Intel MKL. It is not free but it is pretty good. By the way,
it has the PARDISO solver built in. You will need to compile TAUCS the
same way as for AMCL. If you need more instruction in this respect, please.
So, what is the problem between TAUCS and AMCL/MKL? TAUCS expects that
the BLAS function names are low case. It checks if one needs an extra
underscore at the end but it assumes that the functions are in low case.
This is not the case in AMCL/MKL - the BLAS functions there are in upper
case. Hence we have to tell TAUCS to use BLAS functions in upper case as
well. I have put some files that should be modified
http://matrixprogramming.com/TAUCS/BLASuppercase/
1) src/taucs.h
It was necessary to edit it to tell TAUCS that the BLAS names are
upper-case.
2) progs/taucs_blas_nounderscore_test.c
This file is used during TAUCS tests and the BLAS function name has to
be modified here as well.
3) config/win32.mk
It is necessary to specify new location of the libraries. It is assumed
that METIS and ACLM are in external/new
LIBBLAS = external\\new\\libacml.lib
LIBMETIS = external\\new\\libmetis.lib
When these files are changes, the new TAUCS library should use the BLAS
functions in upper case and the command
$ cl test_taucs.obj libtaucs.lib libmetis.lib libacml.lib -link
-LIBPATH:lib/win32 -LIBPATH:external/new
should work.
Once more, the life is not that simple but after all it is not that
complicated either. What is just necessary to understand what is going
on. It also makes sense to invest time to learn about the optimized
BLAS. All solvers depend on it. Without it the performance will be much
worse.
Try to repeat the process and if you will see problems, please ask.
What problems did you have? From cygwin you cannot use backslash - it
plays the role of the escape character. But it happens that cl
understand slash instead. Then to specify flags just use not slash but
minus. This is what I do.
Well, I use tcsh and be default Cygwin uses bash. It could be that there
are some subtle differences between them. Again if you write what
problem you had, I could check. I like Cygwin more than cmd, as the
scripting capabilities are much more flexible.
Instead I
> entered the commands included in the makefiles of metis from visual
> studio command prompt and the library was successfully built.) In order
> to rebuild blas, I chose the second option you have provided. I
> downloaded AMCL and replaced the files youu have mentioned in taucs.
> However I was not able to compile taucs successfully. I got the
> following linking errors:
>
> 1>libtaucs.lib(taucs_vec_base.obj) : error LNK2001: unresolved external
> symbol _scnrm2_
> 1>libtaucs.lib(taucs_vec_base.obj) : error LNK2001: unresolved external
> symbol _dznrm2_
> 1>libtaucs.lib(taucs_vec_base.obj) : error LNK2001: unresolved external
> symbol _snrm2_
> 1>libtaucs.lib(taucs_vec_base.obj) : error LNK2001: unresolved external
> symbol _dnrm2_
These function names are still in low case. I will check why I did not
have this problem.
> 1>libtaucs.lib(taucs_sn_llt_C.obj) : error LNK2001: unresolved external
> symbol _CHERK_
This function and below has underscore at the end. Something went wrong.
You can check build\win32\taucs_config_tests.h. It should have
#define TAUCS_BLAS_NOUNDERSCORE
and it seems that this is not what you have by you.
Presumably this file has not been delete from the previous compile and
something was wrong when TAUCS has made this check.
I will check my procedure once more later today. I have done it fast and
it could be that something was not quite correct.
I have checked. My version of AMCL has these functions in low case in
addition to upper case
$ nm external/new/libacml.lib | grep nrm
dnrm2.obj:
dnrm2_cw.obj:
00000000 T _dnrm2
dznrm2.obj:
dznrm2_cw.obj:
00000000 T _dznrm2
scnrm2.obj:
scnrm2_cw.obj:
00000000 T _scnrm2
snrm2.obj:
snrm2_cw.obj:
00000000 T _snrm2
So, the problem could be not the low case but the underscore at the end.
However, my version of AMCL is not the latest and if you will need to
have these function in upper case please just change the following lines
in taucs.h
$ grep -i nrm src/taucs.h
taucs_double taucs_blas_name(dnrm2)(int*, taucs_double*, int*);
taucs_single taucs_blas_name(snrm2)(int*, taucs_single*, int*);
taucs_double taucs_blas_name(dznrm2)(int*, taucs_dcomplex*, int*);
taucs_single taucs_blas_name(scnrm2)(int*, taucs_scomplex*, int*);
to
taucs_double taucs_blas_name(DNRM2)(int*, taucs_double*, int*);
and so on. I have forgotten to do it.
It seems that AMCL has been compiled with the Intel compiler and depends
on some libraries from it. With MS Visual C it is not that easy to
understand all dependencies as they do it implicitly. The library has a
list of libraries on which it depends written in the lib file. On the
other hand, the libraries are searched automatically with the use of
INCLUDE environmental variable. So with my configuration everything
happened automatically and I have not even mentioned it. It is good to
check the AMCL docs. I have been working lately mostly with Intel MKL
and do not remember everything about AMCL anymore. The simplest way is
to check if the AMCL distribution includes Intel libraries, well, this
actually should be the case, and then to add this path to INCLUDE or
copy them with the AMCL library.
I have made more checks. I still do not remember how I have linked with
libacml.lib earlier. Probably I had already then the Intel Fortran
installed.
When I redefine $LIB (not $INCLUDE - it was my mistake in the previous
email)
$ echo $LIB
C:\Programme\Microsoft Visual Studio 8\VC\LIB;C:\Programme\Microsoft
Visual Studio 8\SDK\v2.0\lib;C:\Programme\Microsoft Platform
SDK\Lib;C:\Programme\Intel\Compiler\Fortran\10.0.025\IA32\Lib;C:\Programme\Intel\MKL\10.0.012\ia32\lib
without the path to the Intel compiler
$ setenv LIB "C:\Programme\Microsoft Visual Studio
8\VC\LIB;C:\Programme\Microsoft Visual Studio
8\SDK\v2.0\lib;C:\Programme\Microsoft Platform SDK\Lib"
then I see your problem when I am linking with libacml.lib
$ cl test_taucs.obj libtaucs.lib libmetis.lib libacml.lib -link
-LIBPATH:lib/win32 -LIBPATH:external/new
The trick with strings shows that libacml.lib depends on many Intel libs
$ strings external/new/libacml.lib | grep default
...
B-defaultlib:ifconsol -defaultlib:libifcoremd -defaultlib:libifportmd
-defaultli
b:libmmd -defaultlib:MSVCRT -defaultlib:libirc -defaultlib:OLDNAMES
-defaultlib:
ifconsol -defaultlib:libifcoremd -defaultlib:libifportmd
-defaultlib:libmmd -def
aultlib:MSVCRT -defaultlib:libirc -defaultlib:OLDNAMES WVUS
so this is not an option if you do not have Intel Fortran installed.
These libs are not supplied with ACML. It seems that they assume that
you will use Intel Fortran. However, what is working is linking with
libacml_dll.lib instead. Copy all libraries from amd32/ifort32/lib to
external/new
$ ls external/new
libacml.lib libacml_dll.lib libmetis.lib
libacml_dll.dll libifcoremd.dll libmmd.dll
Now
$ cl test_taucs.obj libtaucs.lib libmetis.lib libacml_dll.lib -link
-LIBPATH:lib/win32 -LIBPATH:external/new
should work. The executable depends on the ACML and Intel DLLs
$ cygcheck ./test_taucs.exe
.\test_taucs.exe
external\new\libacml_dll.dll
external\new\libifcoremd.dll
C:\WINDOWS\system32\MSVCRT.dll
C:\WINDOWS\system32\KERNEL32.dll
C:\WINDOWS\system32\ntdll.dll
C:\WINDOWS\system32\IMAGEHLP.dll
external\new\libmmd.dll
but it is just necessary to put this directory on the path to be able to
run the executable
setenv PATH external/new:"$PATH"
and by me everything is working. So, just use libacml_dll.lib for
linking. By the way, I have checked - I have used AMCL 3.6 with MS VC
2005 - acml3.6.0-32-ifort.exe.
Well, work with libraries requires some logistics.
What error do you receive when you run the application? Everything is
correct now. These two messages
> Error: Could not find MSVCR90.dll
> Error: Could not find MSVCR80.dll
you can ignore. These are two run-time MS DLL and there is another
mechanism to find it (through the manifest file). The problems start
when you move the application to another computer - then you need to
install MS run-time libraries there. Yet I presume that you do
everything on the same computer.
To be safe copy all dlls from external/new to the application and try to
start it from cmd or just double click it in explorer. Sometimes cygwin
prevents to have the right error message.
I would say that this is a typical error when the run time libraries are
not installed correctly. Can you compile and run any /MD application at all?
I do not think Vista is a problem.
Do you have a manifest file - that is, test_taucs.exe.manifest?
More information about this for example at
http://www.codeproject.com/KB/cpp/vcredists_x86.aspx
but usually it happens when one tries to run the compiled application at
another computer.
I would start with compiling a sample application, say Hello World with
/MD and see if it is working. If not, then you have to install the run
time libraries. I think there should be a link to them on the page
above. They should have been installed automatically with MS VC but ...
If Hello World is working, then it is necessary to find a difference
when you compile the TAUCS example. Well, it could be some other reasons
as well. Anyway first is to check what happens with other /MD
applications and with the manifest files.
Let us do it slowly to make me understand what happens. Could you please
split the next statements to right and wrong?
Compilation of a simple application with /MD is working on Windows XP.
Compilation of a simple application with /MD is working on Vista.
Compilation of taucs_test.exe with /MD is working on Windows XP.
Compilation of taucs_test.exe with /MD is working on Vista.
With computers there are many things that can go wrong - the goal is to
understand when exactly it starts going wrong.
I am glad to here that on XP everything is working. This shows that
everything is okay with the libraries. Actually you do not have to
recompile libraries for XP and Vista, I would expect them to be the same.
It seems that there are some problems with the runtime libs on Vista.
You can check what is written in the manifest. Compare the manifests on
XP and Vista.
Alternatively one can copy the application from XP to Vista. It requires
some more efforts but I was able to do it. This is described in
http://www.codeproject.com/KB/cpp/vcredists_x86.aspx
I was able to do it with my command line application that uses TAUCS.
What if you install the latest runtime libs on Vista? I think this could
be a good starting point. Then check what is in the manifests - what is
the difference between XP and Vista. It could be good to compare the
manifests for the simple application and taucs_test.exe as well.
If the manifests are the same, then something is wrong with the run-time
library on Vista. It certainly should be possible to copy the
application from XP, but you have to include the run-time libs as well.
Well, it is good to learn anyway, as at some point you will probably
need to distribute your application.
You do not need libumfpack.lib and libamd.lib. They are from UMFPACK.
> 1>libtaucs.lib(taucs_sn_llt_C.obj) : error LNK2019: unresolved external
> symbol _cpotrf_ referenced in function _multifrontal_supernodal_front_factor
> 1>libtaucs.lib(taucs_ccs_ooc_llt_C.obj) : error LNK2001: unresolved
> external symbol _cpotrf_
...
> Where should these symbols be defined?
I think in liblapack.a. UMFPACK does not use it and I have not included
it in the list. It should be available in
http://matrixprogramming.com/MatrixMultiply/lib.tar.gz
It is a part of ATLAS. Please rename it to liblapack.lib and include in
the list of libraries to link.
It seems there was some incompatibility between AMCL on Vista. Or it was
just something wrong with that particular Vista. Hard to say. So if you
want to pursue AMCL, it is good first to compile a test with it to make
sure it will work for you.
As for ATLAS, you have
1) recompile TAUCS with /MD (change in win32.mk)
2) recompile METIS with /MD
http://matrixprogramming.com/METIS/
Well, these two steps are actually general.
Then you can go along the lines
http://matrixprogramming.com/UMFPACK/
see here Compiling under MinGW and Using UMFPACK with Microsoft Visual
Studio. You do not need the UMFPACK libraries and you have to add
liblapack.lib. So you can reuse the ATLAS libs that have been compiled
by me. On the other hand, compiling ATLAS is fun. But I am afraid that
the latest version is working only with gcc 4. I have compiled under
Cygwin ATLAS 3.6. This should work.
I will try to make a page on my site about it but I cannot say for sure
when I will have time.
You have to compile TAUCS with -MD, then METIS with -MD. As for BLAS,
there are several options, one of them is to use ATLAS compiled with
gcc. You can use ATLAS 3.6 compiled by me at