Thread: I'm having a hard time making a .exe from a .cpp

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    I'm having a hard time making a .exe from a .cpp

    I have this .cpp file

    GigaSize.com: Host and Share your Files

    Which I downloaded from a site and edited on line (just added an if). I want to build it a generate a .exe, but I don't know exactly how. I have Visual Studio 2005 btw. If you can give me step by step instructions or just generate the .exe file for me I would really apreciate it.

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    42
    I didn't check the file or anything, but since you have the code done, all you have to do is compile it to create the executable.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    Yes, but I don't know how... I need to create a project on Visual Studio, right? I created an Empty Windows project, added the cpp to the source folder. The tried building it. I got some errors on the MessageBox calls, errors like this:

    error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [32]' to 'LPCWSTR'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    After that, I commented every call to MessageBox and got linking errors, like this one:

    1>eDNS.obj : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _WinMain@16

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You should probably start with a "hello world", learn the basics of the language, learn the basics of Windows API and then try to compile that file (don't know what it contains, but it must be quite a big bite for a complete beginner).

    Anyway the error message indicates, that you are trying to compile a Unicode version of the program, but the source only allows it to be compiled as Ansi. (Source should be using const TCHAR [32] to support both.)

    Find where UNICODE is defined (I suppose in project settings somewhere) and remove it.

    (Edit, or actually the error is triggered by a single string literal, which should go inside a TEXT("literal") or T("literal") macro.)
    Last edited by anon; 05-13-2009 at 04:18 PM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    Great! Now I'm just stuck with the linking error, :P. Any help there?

  6. #6
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You know, you are not the first person with this problem. Why not copy the error message (relevant part) into Google's search box and see what it tells you?

    You need to link against some library.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  7. #7
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by anon View Post
    You know, you are not the first person with this problem.
    I had this momentary vision of a blinking .gif file that read: "Congratulations! You're the 1,000,000th person to have this problem! Click here to get your prize!"
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  8. #8
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    I'm looking for it. I can't find the solution. I don't understand many of the solutions either...

  9. #9
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    I keep finding that I have to set the linker to use user32.lib, but that is done already. I can't figure this out.

  10. #10
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    Yeah!!! I was missing wsock32.lib. To think I wrote a C++ VNC three years ago... And of course, I used WinSock. I can't rememember anything though

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And are you linking with the wsocket2 [I think that's the right name] library?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 09:11 AM
  2. Journey time prog 1 minute wrong
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 10-12-2006, 03:41 AM
  3. Making A Random Number Each Time?
    By relyt_123 in forum C++ Programming
    Replies: 6
    Last Post: 07-28-2006, 03:16 PM
  4. online games, making it hard to use hacks
    By muttski in forum Windows Programming
    Replies: 10
    Last Post: 05-13-2002, 10:32 AM
  5. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 06:17 PM