Link to home
Start Free TrialLog in
Avatar of drewbuckley
drewbuckley

asked on

C++ question from a C# programmer

Shoule be an easy question for you c++ people.

I've downloaded and want to work with the JRTPLib which is in C++ and has some examples. These are the .cpp files.
i have VS2008 and i'm not sure how to create a project so that i can test these examples.

i would also like to use these as a starting point for myself to learn C++. You may say that if i cant do this maybe i need to learn C++ from the beginning, well, good point but i haven't the time. Once i can get a project of these .cpp files, i'm confident to learn as i go.

thanks
ASKER CERTIFIED SOLUTION
Avatar of tculler
tculler
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of drewbuckley
drewbuckley

ASKER

Thanks for your time Nate.

I'm sure it's me but this is what i did.
started new project normal empty project and also tried your one, clr empty.
i added a .cpp file and named it "main" and inserted #using "the path to the example cpp file". on compiling i get "C1113 using failed on -----------" if i import the example.cpp into the source folder i then get around 100 errors of ; missing before and such. these errors are coming from the headers of the library that the example is from. i have pointed to this in c++ directories include files.

i think c++ doesn't like me :)
I think you can use the wizard to let VS 2008 build the solution file from the directory containing the source code.(File->New->Project From Existing Code)  May be you have to tweak some project properties like /clr a.s.o

C++ compiler always spit a lott of error messages even on one single error.
Please post the first dozen lines of the error log when you run into trouble.

Hope that helps.

Andy
Whoops, that was my bad. I meant #include, heh. So it'll be

#include "PathToFile.cpp"

The "Pre-Processor" basically searches for this file, and inserts it directly into your file. To indicate header files int he standard library, you use angle brackets (< >) instead of quotes. For example,

#include <iostream>

Includes the standard header file iostream. However, since your files are not in the standard library, you give the path in quotes.

Sorry about that heh,
Nate
Thank you for your help.
I've tried both ways and am getting over 40 errors which is way too many to go through here.

One thing though. I've noticed that there is a Makefile.in and believe that this can make the Projectect but i can't seem to make it happen,

Google has told me to use NMake.exe i have tried c:\NMAKE /f "Makefile.in" amonst other things with no success.

is this right? is there another way?

Once again sorry for my noob questions and i appreciate your help and patience.
Alright, do me a favor; we'll see if this works. Follow these steps:

- Start up VS, and go to the Visual C++ templates section. Create a new Empty Project. There should be nothing in any of your filters.
- Right click on your "Source Files" filter, and click "Add...", "New Item".
- On the left hand side, select the "Code" node from the small tree view.
- Select "C++ File (.cpp)" from the choices. Name it however you feel appropriate. A blank page should show up.
- Type the lame code in the following code snippet.
- Run the solution; a console window should come up and display the String shown below (to the right of the "<<", which is called the Insertion operator in this context. It's not shifting bits.)
#include <iostream>
 
using namespace std;
 
void main()
{
     int test = 0;
     cout << "If this doesn't work, drewbuckley's VS is friggin screwy. Enter a number, we'll keep going, lol *gotta love console apps!*:" << endl;
     cin >> test;
     test *= 2;
     cout << "kk here's your number doubled: " << test;
}

Open in new window

That works and was pretty funny:)
also funny how a C# guy helps another C# guy in C++ ;)

seriously though thanks and what now? i appreciate your time.