1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

build error

Discussion in 'Scripting & Programming' started by Mof, Jul 3, 2009.

  1. Mof

    Mof Megabyte Poster

    526
    2
    49
    Hi remember me, problem is I have an error that i just cant solve so its time to turn to my peers.:dry
    te error is "fatal error LNK1120:" Ive googled it and still cant get my head round it:dunce
    here is te code.
    Code:
    #include <iostream>
    int main()
    {
    	using std::cout;
    	using std::endl;
    
    	unsigned short int smallnumber;
    	smallnumber = 65535;
    	cout << "Small Number:" << smallnumber << endl;
    	smallnumber++;
    	cout << "Small Number:" << smallnumber << endl;
    	smallnumber++;
    	cout << "Small Number:" << smallnumber << endl;
    	return 0;
    }
    thank in advance for your help
     
    WIP: C++ and A+
  2. dmarsh

    dmarsh Terabyte Poster

    3,782
    302
    184
    Are you sure that is the correct main entry point signature for your compiler and project type ?

    For instance my VC++ project I knocked up to test was :-

    int _tmain(int argc, _TCHAR* argv[])

    So if its not what the compiler/linker expects, the linker will complain because it can't find the entry point to your program in any object files and thus you get an 'unresolved external'.

    You are only using STL so there are no obvious library dependencies.

    You may be missing a library dependency otherwise if the entry point is fine. STL library implementations often depend on the C runtime libraries so you might be missing that from your project.
     
    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH
  3. Mof

    Mof Megabyte Poster

    526
    2
    49
    Not sure what you mean by this, the code is from a book that I am following.
     
    WIP: C++ and A+
  4. dmarsh

    dmarsh Terabyte Poster

    3,782
    302
    184
    What compiler are you using ? Are you using VisualC++ and its IDE, if so what type of project is it ? What libraries have you informed the linker to link against ?

    I used the VisualC++ wizard to create a console app, pasted your code in, worked first time.
     
    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH
  5. Mof

    Mof Megabyte Poster

    526
    2
    49
    Visual C++ 2008 Express Edition remember back all those months ago you recomended it and I must say its very user friendly, it not so much a project more a lesson in Wrapping around signed intergers.
     
    WIP: C++ and A+
  6. dmarsh

    dmarsh Terabyte Poster

    3,782
    302
    184
    lol, yes I know, but how did you create your VC++ project ?

    For the IDE to compile and link you have to create a project and add header and source files to said project.

    The easiest way to do this is to do file -> new -> project - > Console application...

    Then just leave the file and replace the body of the main method.

    Later on you can play with project options and turning things on and off.
     
    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH
  7. Mof

    Mof Megabyte Poster

    526
    2
    49
    Thanks for that Dmarsh your right i was trying to use win32 project instead of win32 console application.
    "oops"
     
    WIP: C++ and A+
  8. dmarsh

    dmarsh Terabyte Poster

    3,782
    302
    184
    Depending on the application/project type you get a different entry point on windows.

    Windows applications expect WinMain.

    DLL applications expect DLLMain.

    Console applications expect the standard main.

    Other settings like unicode support can also affect the exact signature but I think the compilers smart enough the do widening and narrowing character conversions and still call your main.
     
    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH

Share This Page

Loading...