Speed Lab

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1145 Views - Last Post: 10 August 2013 - 04:49 PM Rate Topic: -----

#1 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Speed Lab

Posted 08 August 2013 - 08:02 PM

I'm trying to get my program to build (compile) and run. I am new to Visual Studio 2012 and have only gotten the program to run on a Mac. It is a program which converts miles to kilometers. I tried to follow Snoopy's advice and set project -> properties -> linker -> system -> inherit from parent , but the program still doesn't link and I get the error message:

Error 1 error LNK1561: entry point must be defined c:\Users\quang pham\documents\visual studio 2012\Projects\ConsoleApplication49\ConsoleApplication49\LINK SpeedLab

Could anyone tell me what is going on and how to fix it?

My program is:
#include <stdio.h>

FILE *csis;

int main(void)

	//Programmer:  Quang Pham
	//Speed Lab
	//phamquang  005174849

{
float dist = 425.5;
float hr = 7.5;
float meters = 1600 * dist;
float sec = 3600 * hr;
float speed;
float speed2;

csis = fopen("csis.txt", "w");

speed = dist / hr;
speed2 = meters / sec;

printf ("The speed in miles/hr is %f mi/hr.\n", speed);
fprintf (csis, "The speed in miles/hr is %f mi/hr.\n", speed); 
printf ("The speed in meters/sec is %f m/sec.\n", speed2);
fprintf (csis, "The speed in meters/sec is %f m/sec.\n", speed2);

fclose (csis);

return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Speed Lab

#2 salazar  Icon User is offline

  • D.I.C Addict

Reputation: 87
  • View blog
  • Posts: 539
  • Joined: 26-June 13

Re: Speed Lab

Posted 08 August 2013 - 08:27 PM

Have you tried removing the void from main?
Was This Post Helpful? 1
  • +
  • -

#3 jimblumberg  Icon User is offline

  • member icon


Reputation: 3991
  • View blog
  • Posts: 12,315
  • Joined: 25-December 09

Re: Speed Lab

Posted 09 August 2013 - 01:38 AM

Try moving your comments to before the int main(void). Also since your using the outdated Microsoft compiler you probably shouldn't be using the C++ style comments // . Use C style comments instead /* Comment */.

@salazar
There is nothing wrong with the void in the int main(void) call.


Jim
Was This Post Helpful? 1
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Speed Lab

Posted 09 August 2013 - 04:39 AM

Wait a minute,

Quote

I tried to follow Snoopy's advice and set project -> properties -> linker -> system -> inherit from parent


I never said that I said...

select project -> properties -> configuration properties -> linker -> System -> Subsystem
and select Console (/SUBSYSTEM:CONSOLE) from the dropdown list.

Try that and see if that works...

which version of VS are you using incidentally..?

Regards

Snoopy.
Was This Post Helpful? 2
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3467
  • View blog
  • Posts: 10,688
  • Joined: 05-May 12

Re: Speed Lab

Posted 09 August 2013 - 06:12 AM

The OP claims to be using VS2012.

I agree with your guys assessment that it's probably configuration issues as noted in the other thread.

Anyway, Quang Pham I've got the following questions:
1. Is this a version of VS2012 Express that you downloaded directly from Microsoft, or a warez copy you got from someplace else?
2. If you just do the following basic steps (without deviation) can you get a successfully compiled program:
Start Visual Studio 2012
File.New>Project...
Enter "TestMe" for the Name.
Click OK.
Click Finish.
After the Wizard finishes generating code, press F6.
3. For your other program(s) that do not link correctly, can you please attach the .vcxproj files associated with those projects? I'm curious how badly the project configuration has gotten mangled.
Was This Post Helpful? 1
  • +
  • -

#6 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Re: Speed Lab

Posted 09 August 2013 - 06:56 AM

View PostSkydiver, on 09 August 2013 - 06:12 AM, said:

The OP claims to be using VS2012.

I agree with your guys assessment that it's probably configuration issues as noted in the other thread.

Anyway, Quang Pham I've got the following questions:
1. Is this a version of VS2012 Express that you downloaded directly from Microsoft, or a warez copy you got from someplace else?
2. If you just do the following basic steps (without deviation) can you get a successfully compiled program:
Start Visual Studio 2012
File.New>Project...
Enter "TestMe" for the Name.
Click OK.
Click Finish.
After the Wizard finishes generating code, press F6.
3. For your other program(s) that do not link correctly, can you please attach the .vcxproj files associated with those projects? I'm curious how badly the project configuration has gotten mangled.


I tried TestMe and test.c but I got the error messages:
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup c:\Users\quang pham\documents\visual studio 2012\Projects\ConsoleApplication51\ConsoleApplication51\MSVCRTD.lib(crtexe.obj) TestMe
Error 2 error LNK1120: 1 unresolved externals c:\Users\quang pham\documents\visual studio 2012\Projects\ConsoleApplication51\Debug\TestMe.exe TestMe
Was This Post Helpful? 0
  • +
  • -

#7 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Speed Lab

Posted 09 August 2013 - 07:05 AM

Are you running windows 8 ?
Was This Post Helpful? 1
  • +
  • -

#8 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Speed Lab

Posted 09 August 2013 - 10:14 AM

Ok,

For Visual Studio 2012 Desktop here is how to make a Win32 console app.


From the Start Page click on --> New Project

From the Templates Folder click on --> Visual C++

From the Visual C++ Folder click on --> Win32 and select Win32 Console Application

In the Name box type Speed Lab click on --> OK button

This should bring up the Win32 Application Wizard click on --> Next Button do not click on Finish

In the Additional Options: tick the Empty project box.

Click on --> Finish button.

From the PROJECT menu select --> Add New Item

This will bring up the Add New Item Wizard

select C++ File so it is highlighted

in the name box replace Source.cpp with main.c this will then use the C compiler.

click on --> Add

This will then bring up the main.c file in the editor in the main.c document

copy and paste your speed lab C code.

From the BUILD menu select --> Build Solution

this will build the solution you should get a warning about using fopen you can safely ignore this warning
its just a warning about using the microsoft specific version of fopen.

You can now run the solution.

The window will probably disappear however before return 0; you can simply add this line

getchar();



and this will hold the window open to see the results of your program

press Enter key to close the window.

Please let us know if this does not work.


Regards

Snoopy.

This post has been edited by snoopy11: 09 August 2013 - 10:17 AM
Reason for edit:: Spelling mistake

Was This Post Helpful? 1
  • +
  • -

#9 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Re: Speed Lab

Posted 09 August 2013 - 04:16 PM

View Postsnoopy11, on 09 August 2013 - 07:05 AM, said:

Are you running windows 8 ?

I am using Windows 7.
Was This Post Helpful? 0
  • +
  • -

#10 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Re: Speed Lab

Posted 09 August 2013 - 05:32 PM

View Postsnoopy11, on 09 August 2013 - 10:14 AM, said:

Ok,

For Visual Studio 2012 Desktop here is how to make a Win32 console app.


From the Start Page click on --> New Project

From the Templates Folder click on --> Visual C++

From the Visual C++ Folder click on --> Win32 and select Win32 Console Application

In the Name box type Speed Lab click on --> OK button

This should bring up the Win32 Application Wizard click on --> Next Button do not click on Finish

In the Additional Options: tick the Empty project box.

Click on --> Finish button.

From the PROJECT menu select --> Add New Item

This will bring up the Add New Item Wizard

select C++ File so it is highlighted

in the name box replace Source.cpp with main.c this will then use the C compiler.

click on --> Add

This will then bring up the main.c file in the editor in the main.c document

copy and paste your speed lab C code.

From the BUILD menu select --> Build Solution

this will build the solution you should get a warning about using fopen you can safely ignore this warning
its just a warning about using the microsoft specific version of fopen.

You can now run the solution.

The window will probably disappear however before return 0; you can simply add this line

getchar();



and this will hold the window open to see the results of your program

press Enter key to close the window.

Please let us know if this does not work.


Regards

Snoopy.


Thank you for your in- depth answer to my question. I still was unable to build the solution because of two error messages LNK2019 and LNK1120.

Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Quang Pham\Documents\Visual Studio 2012\Projects\ConsoleApplication49\ConsoleApplication49\MSVCRTD.lib(crtexe.obj) SpeedLab
Error 2 error LNK1120: 1 unresolved externals C:\Users\Quang Pham\Documents\Visual Studio 2012\Projects\ConsoleApplication49\Debug\SpeedLab.exe 1 1 SpeedLab

Maybe I will download Microsoft Visual Studio 2012 again and try to run the program. Thanks very much for your attention to my question.
Quang Pham

This post has been edited by Quang Pham: 09 August 2013 - 05:34 PM

Was This Post Helpful? 0
  • +
  • -

#11 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Speed Lab

Posted 10 August 2013 - 03:38 AM

I see,

This sounds like a problem with the .NET framework

make sure you have the 4.5 .NET framework downloaded

it can be found here

4.5 .NET download

or if you re-install VS2012 Desktop Express it should install the 4.5 .NET framework

Also if you go to

Project--> Properties --> Configuration Properties --> Platform Toolset

make sure the Platform Toolset is set to V110 which is the Visual Studio 2012 version.

Regards

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#12 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Re: Speed Lab

Posted 10 August 2013 - 04:44 AM

View Postsnoopy11, on 10 August 2013 - 03:38 AM, said:

I see,

This sounds like a problem with the .NET framework

make sure you have the 4.5 .NET framework downloaded

it can be found here

4.5 .NET download

or if you re-install VS2012 Desktop Express it should install the 4.5 .NET framework

Also if you go to

Project--> Properties --> Configuration Properties --> Platform Toolset

make sure the Platform Toolset is set to V110 which is the Visual Studio 2012 version.

Regards

Snoopy.


I've tried everything. I read the C Programming.com tutorial and tried to use the IntoToC program

 #include <stdio.h>
int main()
{
    printf( "I am alive!  Beware.\n" );
    getchar();
    return 0;
}


but even that program had the two LNK errors when I tried to build it. I redownloaded Visual Studio 2012, downloaded 4.5 .NET, and tried the project -> properties -> configuration properties -> platform toolset -> V110. I am frustrated and perplexed. I wonder what I am doing wrong with Visual Studio 2012? Maybe I will go on Monday to school and ask the Lab Assistant if he could help, though he says he doesn't know much about C, just Java. The school computer is a Mac, though. Thanks, Snoopy, for your help and attention to my problem. Quang Pham
Was This Post Helpful? 0
  • +
  • -

#13 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 762
  • View blog
  • Posts: 2,218
  • Joined: 20-March 10

Re: Speed Lab

Posted 10 August 2013 - 05:06 AM

Well,

The very last thing to try is

Project --> Properties --> Configuration Properties --> Linker --> General

In General there is an option Enable Incremental Linking set this to No (/INCREMENTAL:NO)

Then try to BUILD.

If this doesnt work then I am out of ideas :)/>

Snoopy.

This post has been edited by snoopy11: 10 August 2013 - 05:34 AM
Reason for edit:: Spelling mistake

Was This Post Helpful? 1
  • +
  • -

#14 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1311
  • View blog
  • Posts: 4,503
  • Joined: 19-February 09

Re: Speed Lab

Posted 10 August 2013 - 02:15 PM

View PostQuang Pham, on 09 August 2013 - 04:02 AM, said:

Could anyone tell me what is going on and how to fix it?


Visual Studio is looking for the main function and cannot find it, for some reason.

You can add and remove source files from the project.

Visual C++ 2012 Tutorial


View PostSkydiver, on 09 August 2013 - 02:12 PM, said:

1. Is this a version of VS2012 Express that you downloaded directly from Microsoft...?


Did you get VS from Microsoft?


Check the linker options in Project Properties, Configuration Properties, Linker, Advanced, Entry Point. Try setting that property to main.
Was This Post Helpful? 0
  • +
  • -

#15 Quang Pham  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 66
  • Joined: 18-November 12

Re: Speed Lab

Posted 10 August 2013 - 02:15 PM

View Postsnoopy11, on 10 August 2013 - 05:06 AM, said:

Well,

The very last thing to try is

Project --> Properties --> Configuration Properties --> Linker --> General

In General there is an option Enable Incremental Linking set this to No (/INCREMENTAL:NO)

Then try to BUILD.

If this doesnt work then I am out of ideas :)/>/>

Snoopy.


Thank you for your ideas on how to get the program to build and run.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2