Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / December 2007

Tip: Looking for answers? Try searching our database.

from linux-code to Visual Studio project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cloudy13 - 22 Nov 2007 22:32 GMT
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
Richard - 23 Nov 2007 00:44 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<9FB5BC84-EF68-467C-AD68-C9649DAC04F1@microsoft.com> 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.
Signature

"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/>

cloudy13 - 23 Nov 2007 18:19 GMT
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?
Richard - 23 Nov 2007 20:55 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<22103641-9038-4F1E-A790-94CAB4B833A7@microsoft.com> 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
Signature

"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/>

cloudy13 - 26 Nov 2007 19:22 GMT
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..?
Richard - 26 Nov 2007 19:58 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<19DFBBEF-E3E8-4E47-A127-8BBFE28EAD46@microsoft.com> 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.
Signature

"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/>

cloudy13 - 27 Nov 2007 07:42 GMT
> 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?
Richard - 27 Nov 2007 15:15 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<507EB06C-8E69-480A-9F40-4F6EDD317E74@microsoft.com> 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.
Signature

"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/>

cloudy13 - 29 Nov 2007 03:54 GMT
> 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?
Richard - 29 Nov 2007 04:30 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<E61E30E2-C8DF-426E-A651-7F1086D7C54A@microsoft.com> 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.
Signature

"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/>

cloudy13 - 11 Dec 2007 07:38 GMT
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..?
Richard - 11 Dec 2007 19:51 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<F157E07E-A507-46D0-97CD-F708534A0F75@microsoft.com> thusly:

>I got now this kind of errors:
>
[quoted text clipped - 4 lines]
>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.
Signature

"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/>

cloudy13 - 12 Dec 2007 12:43 GMT
> 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.
Richard - 12 Dec 2007 18:13 GMT
[Please do not mail me a copy of your followup]

=?Utf-8?B?Y2xvdWR5MTM=?= <cloudy13@discussions.microsoft.com> spake the secret code
<3AE59B0E-37FF-4B2F-8162-843B92B0040E@microsoft.com> 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.
Signature

"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/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.