Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C++ Help

Options
  • 13-01-2008 1:40pm
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭


    Hi, I am trying to edit a program that i was given by a company, for a college project. It is a .exe that reads data from a usb device to a console. I don't know any C++ really but that shouldn't be a problem. My problem is setting up the project. If it won't build at the start I can hardly start editing it.

    I go to create project from existing code and add in all the files by browsing for the directory. When I try to build the program I get an error.

    Build started: Project: as, Configuration: Debug Win32
    Compiling...
    Rges.c
    d:\project\one\pcdevelopment\programsample\rges\rges.c(18) : fatal error C1083: Cannot open include file: 'MfRc500.h': No such file or directory
    Build log was saved at "file://d:\Project\one\PCDevelopment\ProgramSample\Rges\Debug\BuildLog.htm"
    as - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Now, MfRc500.h is clearly a file and it is in the project, I can view it. If I comment out the #include MfRc500.hit says the next header file does not exist, and so on.
    Anybody know how I can fix this?

    Thanks,

    --
    Tar


Comments

  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    What directory is the header file (.h) in?
    Is it in the same directory as the source file (.cpp) that you are compiling?

    Try using #include <xxx.h> if the file is a standard library that came with the compiler
    or #include "xxx.h" if the file is in the same directory as the source file.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    It is here: D:\Project\one\PCDevelopment\ProgramSample\Rges which is the same directory.


  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    Is the header file included using the line #include "MfRc500.h"?

    I noticed as well that the file you are trying to compile is .c as opposed to .cpp.
    I.e. your comiling a C program not C++.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Here is what it looks like at the moment, after I add the directory to the project, the .lib files, .dll files and .exe file are not included in the project, I do nt know if I have to right click on them and include them or leave them excluded. I think they should be excluded?

    It is included by the line #include <MfRc500.h>

    example.jpg


  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    Well if MFrc.h is part of your project and isn't a system file then I'd
    include it as "MfRc500.h" instead of <MfRc500.h>.


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Thank you, for each header fill I keep changing <> to "". That seem to stop it saing the file did not exist.
    I then tried to compile main.cpp again and it said that windows.h did not exist. this is a header inside MfRc500.h
    error.jpg
    // General Include File for serveral defines concerning conditional library
    // compilation and microcontroller usage
    #include "windows.h"
    This windows.h does not exist in any project folder, is it from windows itself?


    EDIT: Found this, that could be the cause maybe?
    I am using express, maybe I should get something else?
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1760350&SiteID=1


  • Registered Users Posts: 8,584 ✭✭✭TouchingVirus


    When you include files like this

    #include "myheader.h"

    Then myheader.h should be in the same directory as the source code. If it's not then there will be a compiling problem.

    If there is no windows.h in your source code directory then you can either find a copy and put in in there, or the chances are if you change the line to read

    #include <windows.h>

    it will work - since windows.h exists in Visual Studios includes/libraries.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion



    If there is no windows.h in your source code directory then you can either find a copy and put in in there, or the chances are if you change the line to read

    #include <windows.h>

    it will work - since windows.h exists in Visual Studios includes/libraries.

    Apparently the windows.h does not exist in Visual C++ express edition and I have to do a work around. Maybe I should use a different compiler?

    Any suggestions for a good one?


  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    As a previous poster said.
    System libraries (libraries that come with the compiler) such as iostream.h, fstream.h, etc. need to be included like this <iostream.h>.
    Libraries you add yourself such as say dog_cat.h you should include as "dog_cat.h".

    RE windows.h, try downloading the windows SDK for Visual Studio from here
    http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    I'm trying to get the xp verion atm, that is for 2003. Downloading atm.
    I know about the difference between "" and <> now thanks.


  • Advertisement
  • Registered Users Posts: 8,584 ✭✭✭TouchingVirus


    I'm trying to get the xp verion atm, that is for 2003. Downloading atm.
    I know about the difference between "" and <> now thanks.

    Ahh, my mistake, I didn't see the express bit :p Grabbing the Windows SDK should do the trick ;)

    Also from the above webpage that Armin Tamzarian linked :
    The Microsoft ® Windows® Software Development Kit (SDK) provides the documentation, samples, header files, libraries, and tools you need to develop applications that run on Windows. The applications you develop with this edition of the SDK can run on the x86, x64 and Itanium-based versions of Windows Server 2003, Windows Server 2003 R2, Windows XP SP2, Windows XP x64 Pro Edition, and Windows 2000. The Web install allows you to select components you wish to install on a more granular level


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Thanks guys, I got the SDK, copied over what was needed. I still had errors but I have them fixed thanks to grasshoppa


  • Closed Accounts Posts: 10,833 ✭✭✭✭Armin_Tamzarian


    Thanks guys, I got the SDK, copied over what was needed. I still had errors but I have them fixed thanks to grasshoppa

    Nice one, glad you got it working.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Thanks. :)


Advertisement