Hi, I got a code that has been run through with linux-system but I need to use Windows machine with Visual Studio 2005 (Professional x64). I know hardly anything about Visual Studio so that I would need some help to make a Visual Studio project to run the code through. It is written with C, uses MPI and includes Makefile. Thanks
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >Windows machine with Visual Studio 2005 (Professional x64). I know hardly >anything about Visual Studio so that I would need some help to make a Visual >Studio project to run the code through. It is written with C, uses MPI and >includes Makefile. It will help if you read through the documentation on Visual Studio and C++ Projects first. After reading through that (you don't have to read every word, but spend some time reading what's relevant -- it will make a huge difference in what you're doing), you can either create a project from the Makefile or create a C++ project and add the sources to that project. I recommend the latter. Why? Because your Makefile isn't going to work well on Windows anyway, since it was made for unix. The Makefile project type in Visual Studio is meant for converting existing Windows projects that are Makefile based, not for converting linux projects. In addition to those options that exist entirely within Visual Studio, you have the option of adopting a build tool that is cross platform. Boost has bjam and there are a couple more out there whose name escapes me at the moment. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Nice to hear that you can help. What I have done untill now is that: I created a new project, Win32 Console Application from Visual C++ and added all the existing .h files to the header files and .c files to the source files. The original code includes also some files that does not have ending and includes some values, and seperate foulder which changes all the results to the format that MatLab is able to read them. I don't know what to do with them. Anyway, I built the project and got errors for all c-files: fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? At that point I realized I would need help.. So what can I do next?
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >I created a new project, Win32 Console Application from Visual C++ >[...] When you created this project, you selected "Use precompiled headers" (its checked by default). >Anyway, I built the project and got errors for all c-files: > >fatal error C1010: unexpected end of file while looking for precompiled >header. Did you forget to add '#include "stdafx.h"' to your source? This is because you created the project using precompiled headers. You can do one of the following: - recreate the project without using precompiled headers - include stdafx.h in all your .c files - change the properties for the project/files to not use precompiled headers -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
ok, now I have fixed that precompiler problem. The code uses some basic libraries. Building the code ended for not finding gsl/gsl_rng.h Commands in the code are: #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> Does not Visual Studio include them..?
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >Commands in the code are: >#include <gsl/gsl_rng.h> >#include <gsl/gsl_randist.h> >Does not Visual Studio include them..? I never heard of "gsl" before. What is it? Is it this? <http://www.gnu.org/software/gsl/> If so, download it, then go to Tools / Options / Projects and Solutions / VC++ Directories and add the appropriate paths to the include and library search paths. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
> I never heard of "gsl" before. What is it? Is it this? > <http://www.gnu.org/software/gsl/> yes, it is that one. It looks like gsl is suitable for linux-system but it is possible to use it only through Cygwin when using Windows. I'm not quite sure if it is a good idea to open those packages from inside the program. Instead I installed gsl (for linux) and checked how it works to include the paths from there. Visual Studio did not find them after including the path names to the VC++ Directories. I wonder if there was something else I should have known when including them or if it was that Visual Studio was not able to read them. Error is: Cannot open include file: 'gsl_rng.h': No such file or directory. (I needed to change the earlier gsl/gsl_rng.h to gsl_rng.h) Anyway, I believe that I should run Cygwin to be able to run gsl (I hope someone will correct me if I am wrong...). So, am I able to run another program to run part of the code? Or is there anything similar in Visual Studio that I would be able to use instead?
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >Error is: > Cannot open include file: 'gsl_rng.h': No such file or directory. >(I needed to change the earlier gsl/gsl_rng.h to gsl_rng.h) Then you didn't set the path search directory properly. Check it again. There is a combo box that you have to select "include files" and "library files" for the appropriate path. Its common for GNU packages to say they run under cygwin because then they're compiling with gcc. That doesn't mean you can't compile them with visual studio, it just means they've only tried it with gcc. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
> Then you didn't set the path search directory properly. It seems to work now. Then next question: The code has a command #include <mpi.h> which is used if mpi is defined. The code can be used both series and parallel. Now I suppose, Visual Studio takes care of the parallel run. Can I just take those commands away? Is there something else instead?
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >Then next question: >The code has a command >#include <mpi.h> >which is used if mpi is defined. The code can be used both series and >parallel. Now I suppose, Visual Studio takes care of the parallel run. Can I >just take those commands away? Is there something else instead? OK, the bottom line with all these sorts of things is that before you can port any software from *nix to Windows, you have to know what else the source code depends on. You've already identified GNU scientific library and now something called <mpi.h>. Anything that is *not* a standard C library header or a standard C++ library header will require porting along with the application. Its up to you to identify all those dependencies and find their Windows equivalent -- either by compiling them on Windows or obtaining a prebuilt Windows package you can compile and link against. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Hi, I am back. Thank you for the help until now. I have intsalled some couple of libraries and fixed some parameter-problems. Now I would need help again. I got now this kind of errors: error LNK2005: _main already defined in hydrate2D.obj error LNK2019: unresolved external symbol _gsl_rng_set referenced in function _main There is three errors of the last type, all of them are situated in main.obj What are those errors about..?
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >I got now this kind of errors: > >error LNK2005: _main already defined in hydrate2D.obj >error LNK2019: unresolved external symbol _gsl_rng_set referenced in >function _main > >There is three errors of the last type, all of them are situated in main.obj >What are those errors about..? How much programming have you done in C/C++? These errors are saying you have the same function defined twice and you are referencing functions that you haven't linked into your executable. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>
> How much programming have you done in C/C++? Well,.. Basic studies, but it is not my main sublect and I have not really been coding myself. But I suppose I wrote the question a bit wrong.. I know what is written in there. I do not know what I can do for it. > These errors are saying you have the same function defined twice and > you are referencing functions that you haven't linked into your > executable. main is defined on a project front page but I do not find _main anywhere. So it is not something I know. And those gsl_whatever are library parameters. How can they be defined twice or not at all? And the problem was really that, where should I go if I need to solve it? Suppose not to main.obj anyway.
[Please do not mail me a copy of your followup] =?Utf-8?B?Y2xvdWR5MTM=?= spake the secret code thusly: >> These errors are saying you have the same function defined twice and >> you are referencing functions that you haven't linked into your >> executable. >main is defined on a project front page but I do not find _main anywhere. main is defined twice in your code. When the C/C++ compiler takes a function and builds a linker symbol out of it, it prepends the "_" to the name of the function. Visual Studio includes a tool called "dumpbin" that will dump out the contents of a Windows executable binary. You can run dumpbin on exe, dll, lib and obj files to see what's inside them in a human readable form. If you do that, you'll see the kinds of things the compiler and linker do to your source code names as they are compiled and made ready for linking. >So >it is not something I know. And those gsl_whatever are library parameters. >How can they be defined twice or not at all? And the problem was really that, >where should I go if I need to solve it? Suppose not to main.obj anyway. Symbols remain undefined after linking if no link input defines the symbol. To resolve undefined symbol errors, you generally add more code to the project (that defines the symbols via source code, creating object files that are fed to the linker to resolve the symbol) or add more link inputs (obj, lib files) to your link properties. Symbols defined more than once are the cause of multiply defined symbol errors. The symbol can be defined more than once because you're defining it more than once in source code or because you've defined it in source code and linked against an input that also defines it. The detailed error message should tell you the offending objects that are multiply defining the symbol. -- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://www.xmission.com/~legalize/book/download/index.html> Legalize Adulthood! <http://blogs.xmission.com/legalize/>