giac development, vla and msvc

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

Répondre
jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

giac development, vla and msvc

Message par jocaps » jeu. oct. 26, 2017 3:35 pm

I am slowly trying to look at possibilities to compile giac in visual studio (which I was hoping to do a very long time already).

What I noticed though is that the giac code has been written in a very non-uniform way. There are places in the code where there are heavy use of VLA (variable length arrays) and there are places where the traditional "new" and "delete" are used to allocate such arrays (this can be seen in a lot of places in vecteur.cc and this is more so when pthread is enabled). Unfortunately, VLA is not supported by MSVC and probably will not be in the near future:
https://msdn.microsoft.com/en-us/library/zb1574zs.aspx

So aside from gmp (where mpir gives hope) there are other hurdles for compiling giac in MSVC. And I cannot see any other easy way to compile giac than to fork the code and try to convert the C99 VLA to traditional new and delete. This is my line of action right now. Just out of curiousity though, has anyone been able to successfully compile giac in MSVC? If not, this is what I will try for now and try to report the progress ocassionally in this forum.

There is another thing that caught my attention when trying to read the code. I am looking at vecteur.cc and I see a lot of similar code lines (and these are not just one or two lines) repeated several times. There is still good room for code optimization here (e.g. to call a procedure that execute these lines than to just write them all the time). I don't dare to change the code a lot because I can introduce a lot of bug. So my initial objective is just to first successfully compile in MSVC before trying any code optimization.

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » ven. oct. 27, 2017 7:13 am

giac is compilable under visual c++ with the adequate preprocessor defines. Try these preprocessor defines:

Code : Tout sélectionner

WIN32
WINDOWS
HAVE_CONFIG_H
NO_UNARY_FUNCTION_COMPOSE (option)
STATIC_BUILTIN_LEXER_FUNCTIONS (option)
IN_GIAC
USE_GMP_REPLACEMENTS (if using tommath instead of gmp)
GIAC_VECTOR
__VISUALC__
NO_PHYSICAL_CONSTANTS (option)
NO_STDEXCEPT (option)
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_CRT_NON_CONFORMING_SWPRINTFS
You might also have a look at geogebra, I'm not sure what the status is here.

There are optimizations in vecteur.cc (in other files too, e.g. cocoa.cc) with loop unrolling and type specialization. This unfortunately makes the code harder to read. There is certainly room for improvement, but I don't want to break or slow down something.

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » dim. oct. 29, 2017 7:17 pm

Thank you Bernard. The preprocessor definition were not the only things needed to make it compile.

I had to do some other things to make it work. I was finally able to compile and link in VS2008 (even as a dynamic library) with mpir and mpfr dependencies. I do have pthread version for msvc but I was forced to leave it out because if you enable it you get a lot of vla declarations (the developers may not have realized that this will fail in msvc for windows). The end-result is an optimized 8Mb giac dll which I was able to dynamically link with a test program.

I will write more about the exact steps and share it in a link (in this thread) soon.

Jose

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » lun. oct. 30, 2017 7:22 am

Indeed, the threaded parts of giac were never compiled under vc++, there are certainly variable arrays remaining here, I will have a look when I have some time, perhaps alloca will fix some of them easily.

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » jeu. nov. 09, 2017 9:06 pm

Hi,

As promised here are the detail of how I compiled in msvc (you will also see all other steps I made that I have not mentioned in this thread):

http://wp.jocaps.public.linz.at/?p=156

Jose

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » ven. nov. 10, 2017 12:46 pm

I have made a few changes to the source from your blog and I have updated https://www-fourier.ujf-grenoble.fr/~pa ... 4.9.tar.gz
Now, I'd like to build libgiac from your project file, but I'm afraid I need some assistance.
I couldn't compile mpir 3, but I could compile mpir 2.7, the gc version. Where should I copy the headers and libraries?
It seems I must also add include and libs somewhere in the Project Properties, can you elaborate a bit?
Thanks in advance.

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » sam. nov. 11, 2017 8:03 am

Thanks for taking a look at this. I use mpir 2.7.2. I will be glad to assist if I can.

I will try to help. But if you are using the project file from my blog (or the project file I attach in the end of this post) make sure you are in the "Release" build. Because the project file from my blog is set up only for the release build (procedure for setting debug and other build are similar though).

You can copy the headers and binaries in any location you want as long as you refer them properly in the project properties. As an example, let us use relative directory with respect to the project file (so everyone can use it). In the vs_giac directory create a directory ".\mpir\2.7.2\bin\release" and ".\mpir\2.7.2\inc". You can put the .lib and .dll files that you built in release configuration (mpir.dll and mpir.lib) in ".\mpir\2.7.2\bin\release" and you can put all the header files in ".\mpir\2.7.2\inc". The binaries should contain both mpir.dll and mpir.lib because microsoft mangles the method names in a different way than gcc and the lib is necessary when linking. Needless to say, the mpir.dll and mpir.lib should be compiled by the same compiler (i.e. we cannot use a .lib created by gcc and link with msvc).

After choosing an appropriate directory for binaries and headers (let us continue with my above example for directory names), you can set them up in the project properties. You refer the necessary files in project properties in the following way:
Choose Project Properties -> Configuration Properties -> C/C++ -> General
In the field "Additional Include Directories", make sure you add your header directory. For our example: "..\mpir\2.7.2\inc", .. because project file lies in .\vs2008 and we had to go to the root directory. Directory path can also be absolute (in my project file there is an mpfr directory line, perhaps delete this first, because it uses an environment variable specific of my system).

Image

I wanted to created a dll file, apparently the project file in my blog is set to static build, you can set this up
"Configuration Properties -> General and change the filed "Configuration Type" to "Dynamic Library (.dll)"
Choose Project Properties -> Configuration Properties -> Linker -> Input
In the field "Additional Dependencies", make sure you add the full path of the .lib file of mpir. For our example: "..\mpir\2.7.2\bin\release\mpir.lib". File path can also be absolute.

Image
Image

As a side note:
I shared VS2008 project files but they are forward compatible to newer versions of Visual Studio. The project properties can also be changed manually changed in a text editor by editing the vcproj file (which is just an XML-based file format). For instance, "AdditionalIncludeDirectories" is in a "Tool" tag of the "Release" configuration. Similarly to "AdditionalDependencies" (where the .lib files need to be referred).

I also linked to mpfr in a similar fashion.

Please let me know if you could first compile the whole project. If not, please let me know of the errors you encounter.
Visual studio allows a (rather fast) compile of the whole project sources without going through unecessary linking. If that is successful, then we can proceed with the linking/building.

If it helps here is a project file based on the above example (again make sure you work in Release configuration, VS always first switches to Debug configuration when you open the project file directly). You can replace the project file with the one you downloaded from the blog post. You can save the file from the browser because I cannot seem to set "force download" in this forum if the link is to a text based file.

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » sam. nov. 11, 2017 9:12 am

Thank you for your help, but I can't find where the mpir headers are or should be, I don't have a mpir/inc directory, and since I did not make something similar to make install under Unix there is no /usr/local/include directory where MPIR headers would have been installed. I probably miss something obvious for trained Visual C++ programmers, but it's totally unusual for Unix programmers :-)

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » sam. nov. 11, 2017 12:53 pm

Sorry for the inconvenience. To make it easier, I have included the include files of mpir and mpfr in the archive. I also included a solution that if you open you will (hopefully) start with the release:

https://dl.dropbox.com/s/d1h9mxtwibwogah/vs_giac.7z

You said you have already built mpir (and maybe also mpfr?) with visual studio. So I suppose you have the output mpir.lib and mpir.dll? If so, you can put it in the directory ./vs_giac/mpir/2.7.2/bin/release (for mpir) and directory ./vs_giac/mpfr/bin/release (for mpfr.lib and mpfr.dll). I have included the headers of mpir in the archive file provided above. This is described in readme.txt of vs_giac directory.

I could theoretically provide mpir and mpfr binaries, but if someone uses another version of visual studio he will need another set of binaries. Please let me know how you have progressed.

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » sam. nov. 11, 2017 2:58 pm

I did not build mpfr and could only get the static mpir library, therefore I disabled HAVE_LIBMPFR in config.h. The library now compiles (with warnings see at the end) but does not link:

Code : Tout sélectionner

------ Début de la génération : Projet : libgiac, Configuration : Release Win32 ------
     Création de la bibliothèque Release\libgiac.lib et de l'objet Release\libgiac.exp
LINK : warning LNK4098: conflit entre la bibliothèque par défaut 'LIBCMT' et les autres bibliothèques ; utilisez /NODEFAULTLIB:library
alg_ext.obj : error LNK2001: symbole externe non résolu "class giac::dbgprint_vector<class giac::gen> __cdecl giac::gen2vecteur(class giac::gen const &)" (?gen2vecteur@giac@@YA?AV?$dbgprint_vector@Vgen@giac@@@1@ABVgen@1@@Z)
alg_ext.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::exact(class giac::gen const &,class giac::context const *)" (?exact@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
csturm.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::complex_sort(class giac::gen const &,class giac::gen const &,class giac::context const *)" (?complex_sort@giac@@YA_NABVgen@1@0PBVcontext@1@@Z)
csturm.obj : error LNK2001: symbole externe non résolu "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl giac::print_DOUBLE_(double,unsigned int)" (?print_DOUBLE_@giac@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@NI@Z)
derive.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_coordonnees" (?at_coordonnees@giac@@3QBUunary_function_ptr@1@B)
derive.obj : error LNK2001: symbole externe non résolu "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl giac::gen2tex(class giac::gen const &,class giac::context const *)" (?gen2tex@giac@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVgen@1@PBVcontext@1@@Z)
derive.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_cylindre" (?at_cylindre@giac@@3QBUunary_function_ptr@1@B)
derive.obj : error LNK2001: symbole externe non résolu "class giac::dbgprint_vector<class giac::gen> __cdecl giac::plotpreprocess(class giac::gen const &,class giac::context const *)" (?plotpreprocess@giac@@YA?AV?$dbgprint_vector@Vgen@giac@@@1@ABVgen@1@PBVcontext@1@@Z)
derive.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_sphere" (?at_sphere@giac@@3QBUunary_function_ptr@1@B)
derive.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_pnt" (?at_pnt@giac@@3QBUunary_function_ptr@1@B)
desolve.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_point" (?at_point@giac@@3QBUunary_function_ptr@1@B)
desolve.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_cSolve(class giac::gen const &,class giac::context const *)" (?_cSolve@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
gauss.obj : error LNK2001: symbole externe non résolu "void __cdecl giac::ck_parameter_u(class giac::context const *)" (?ck_parameter_u@giac@@YAXPBVcontext@1@@Z)
gauss.obj : error LNK2001: symbole externe non résolu "void __cdecl giac::ck_parameter_v(class giac::context const *)" (?ck_parameter_v@giac@@YAXPBVcontext@1@@Z)
gauss.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_hyperplan" (?at_hyperplan@giac@@3QBUunary_function_ptr@1@B)
gauss.obj : error LNK2001: symbole externe non résolu "void __cdecl giac::ck_parameter_y(class giac::context const *)" (?ck_parameter_y@giac@@YAXPBVcontext@1@@Z)
gauss.obj : error LNK2001: symbole externe non résolu "void __cdecl giac::ck_parameter_t(class giac::context const *)" (?ck_parameter_t@giac@@YAXPBVcontext@1@@Z)
...
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_rsolve(class giac::gen const &,class giac::context const *)" (?_rsolve@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_revlist(class giac::gen const &,class giac::context const *)" (?_revlist@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_delrows(class giac::gen const &,class giac::context const *)" (?_delrows@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_cercle(class giac::gen const &,class giac::context const *)" (?_cercle@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_logb(class giac::gen const &,class giac::context const *)" (?_logb@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_colNorm(class giac::gen const &,class giac::context const *)" (?_colNorm@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_mRowAdd(class giac::gen const &,class giac::context const *)" (?_mRowAdd@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_rowSwap(class giac::gen const &,class giac::context const *)" (?_rowSwap@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
rpn.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_dim(class giac::gen const &,class giac::context const *)" (?_dim@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
series.obj : error LNK2001: symbole externe non résolu "class giac::dbgprint_vector<class giac::gen> __cdecl giac::quote_eval(class giac::dbgprint_vector<class giac::gen> const &,class giac::dbgprint_vector<class giac::gen> const &,class giac::context const *)" (?quote_eval@giac@@YA?AV?$dbgprint_vector@Vgen@giac@@@1@ABV21@0PBVcontext@1@@Z)
series.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_about(class giac::gen const &,class giac::context const *)" (?_about@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_numer(class giac::gen const &,class giac::context const *)" (?_numer@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::f5(class giac::vectpoly &,class giac::gen const &)" (?f5@giac@@YA_NAAVvectpoly@1@ABVgen@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::greduce8(class giac::vectpoly const &,class giac::vectpoly const &,struct giac::order_t &,class giac::vectpoly &,struct giac::environment *,class giac::context const *)" (?greduce8@giac@@YA_NABVvectpoly@1@0AAUorder_t@1@AAV21@PAUenvironment@1@PBVcontext@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_count_eq(class giac::gen const &,class giac::context const *)" (?_count_eq@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::cocoa_greduce(class giac::vectpoly const &,class giac::vectpoly const &,class giac::gen const &,class giac::vectpoly &)" (?cocoa_greduce@giac@@YA_NABVvectpoly@1@0ABVgen@1@AAV21@@Z)
solve.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::cocoa_gbasis(class giac::vectpoly &,class giac::gen const &)" (?cocoa_gbasis@giac@@YA_NAAVvectpoly@1@ABVgen@1@@Z)
solve.obj : error LNK2001: symbole externe non résolu "bool __cdecl giac::gbasis8(class giac::vectpoly const &,struct giac::order_t &,class giac::vectpoly &,struct giac::environment *,bool,bool,int &,class giac::context const *,bool)" (?gbasis8@giac@@YA_NABVvectpoly@1@AAUorder_t@1@AAV21@PAUenvironment@1@_N4AAHPBVcontext@1@4@Z)
solve.obj : error LNK2001: symbole externe non résolu "int giac::gnuplot_pixels_per_eval" (?gnuplot_pixels_per_eval@giac@@3HA)
symbolic.obj : error LNK2001: symbole externe non résolu "int __cdecl giac::gnuplot_show_pnt(struct giac::symbolic const &,class giac::context const *)" (?gnuplot_show_pnt@giac@@YAHABUsymbolic@1@PBVcontext@1@@Z)
usual.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_parameter(class giac::gen const &,class giac::context const *)" (?_parameter@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
usual.obj : error LNK2001: symbole externe non résolu "struct giac::unary_function_ptr const * const giac::at_oufr" (?at_oufr@giac@@3QBUunary_function_ptr@1@B)
vecteur.obj : error LNK2001: symbole externe non résolu "class giac::gen __cdecl giac::_sorta(class giac::gen const &,class giac::context const *)" (?_sorta@giac@@YA?AVgen@1@ABV21@PBVcontext@1@@Z)
Release\libgiac.dll : fatal error LNK1120: 615 externes non résolus
========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========
There are also many worrying warnings from mpir during compilation about conversions:

Code : Tout sélectionner

C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(121): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(167): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(218): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(291): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(335): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(343): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(380): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(427): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(434): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(462): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(547): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(595): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(631): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(699): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(744): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(786): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(796): warning C4146: opérateur moins unaire appliqué à un type non signé, le résultat sera non signé
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1546): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1547): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1613): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1614): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1674): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1675): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1676): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1677): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1678): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1679): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1680): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1681): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1758): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1759): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1841): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1843): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1981): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1983): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1984): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(1986): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2072): warning C4244: 'argument' : conversion de '__int64' en 'mpir_si', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2074): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'mpir_ui', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2118): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2119): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2120): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2121): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2122): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2123): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2124): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(2125): warning C4800: 'int' : valeur forcée à la valeur booléenne 'true' ou 'false' (avertissement sur les performances)
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3275): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3275): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3276): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3276): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3277): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3277): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3278): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3278): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3279): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3279): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3281): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3281): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3282): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3282): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3283): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3283): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3293): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3293): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3294): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3294): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3295): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3295): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3296): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3296): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3306): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3306): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3307): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3307): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3308): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3308): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3309): warning C4244: 'argument' : conversion de '__int64' en 'const long', perte possible de données
C:\cygwin\home\parisse\giac\vs_giac\mpir\2.7.2\inc\gmpxx.h(3309): warning C4244: 'argument' : conversion de 'unsigned __int64' en 'const unsigned long', perte possible de données

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » sam. nov. 11, 2017 9:30 pm

Ah. At least compilation was successful. Let us try to improve the linking. The warnings that you see are unfortunately due to the fact that microsoft compilers treat some types differently than gcc (I think newer VS version behave better but at the moment I prefer using VS2008 unless there is no other choice). For instance for VS compiler for C++ not to give a warning that you write, you need to write your for loops with variables following the type of the ranges, i.e. if you have a std::vector variable v then v.size() is of type size_t (not int). If you do a for loop up to v.size() for an integer variable (like the code below) you will recieve the warning.

Code : Tout sélectionner

for (int i=0; i<v.size(); ++i)
{ }
These are non-serious warnings and to remedy them without ignoring you either have to develop some nasty preprocessor definition or change the variables of all such loops (which is an awful lot of work). I would just ignore the warnings. I uploaded a new vcproj file that does so. VS2008 that I use do not do automatic casting for some types (e.g. typing bool i = 0 produces similar warnings). In my codes, I am careful to cast properly and enable all warnings, but I cannot expect that from other developers using other systems and compilers.

Regarding your link error. I underestimated the usefulness of CMAKE here (which allowed me to produce a dynamic library without exporting preface in the methods, which is usual of VS. Here VS, if I am correct, believes you want to export a dll). Try first to do a static library link. I have set this up in the new vcproj I uploaded. Try to replace your old vcproj file with this one (right click and save as in your browser, phpbb does not allow me to force save links):

https://dl.dropboxusercontent.com/s/5d8 ... iac.vcproj

This should help you link and create a libgiac.lib (not libgiac.dll). I am still using mpfr in the project (if you do not have it, please remove the mpfr.lib in the project properties -> Configuration properties -> Librarian -> General under the "Additional Dependencies" field). Once you are successful with static linking and want also dynamic linking I can guide you through CMAKE. First let us resolve static linking though.

If you compile in VS2008 then I can also provide you a static and dynamic binary just to test. Otherwise this should be done in your own VS compiler.

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » dim. nov. 12, 2017 8:22 am

The static library is now built, great!
I removed linking to libmpfr.a, I checked that

Code : Tout sélectionner

..\inc\giac
and

Code : Tout sélectionner

..\mpir\inc
are in the include directory. The preprocessor directives are:

Code : Tout sélectionner

WIN32
_DEBUG
TEMPLATE_EXPORTS
notINCLUDE_TEST_MODE
WINDOWS
HAVE_CONFIG_H
NO_UNARY_FUNCTION_COMPOSE
STATIC_BUILTIN_LEXER_FUNCTIONS
IN_GIAC
GIAC_VECTOR
__VISUALC__
NO_PHYSICAL_CONSTANTS
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_CRT_NON_CONFORMING_SWPRINTFS
NO_CLOCK
HAVE_NO_CWD
MS_SMART
I'm still concerned by some removed warnings, like conversion from __int64 to const long, in 32 bits mode, this loose the higher part of the int, and in 64 bits mode I'm not certain it's safe (it is with gcc but with vc++?)

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: giac development, vla and msvc

Message par jocaps » dim. nov. 12, 2017 10:17 am

You can re-enable the warnings by switching the warning levels in project properties Configuration Properties -> C/C++ -> General and under the field "Warning Level" change the level of the warning (I usually have it to Level 3). You can also specifically disable special warnings you are sure that are "safe".

I understand your concern about the warnings. Sadly, my experience in developing under non-32-bit is minimal. There is 64 bit support in VS2008, but since I only develop under a 32 bit operating system I cannot test this. In fact the project that I offered were all target for x86 (32 bit). You can however try several things:

1. Try to change the build target to 64 bit and see if the warnings change: I am not sure how this is done for static libraries (for dynamic libraries this is much easier). But I suspect you just have to go to project properties Configuration Properties -> Librarian -> Command Line and in the field "Additional options" type the command : /MACHINE:X64. For better organisation you may want to add x64 configuration by going to the menu Build->Configuration Manager and add the solution platform x64.

2. Develop in a higher version of visual studios where these warnings are better treated and 64 bit is even better supported (e.g. VS2015 or VS2017 which are available for free but very heavy softwares, I think they will require around 10Gb of hard disk space). I tried sometimes using these IDE but they were slow and too heavy for my purposes.

3. The most accurate test is to make a short C/C++ program that checks the conversion of say __int64 to long. And if you are satisfied with these conversion for 64 bit development you can safely specifically ignore these warnings if they appear. In general I suspect you don't get these warning in VS2015 and VS2017 and the conversion of basic types are safe as long as the bit length of the types are the same . This is described a bit here: https://msdn.microsoft.com/en-us/library/hh279667.aspx
and in this stackoverflow post.

parisse
Messages : 5112
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: giac development, vla and msvc

Message par parisse » dim. nov. 12, 2017 1:47 pm

I just checked and long is 32 bits in visual c++. It's a little bit strange that MPIR headers (even in version 2.7) have these warnings.

Répondre