Header files / libraries with Visual C++ 2008

Oct 11, 2008 at 6:08am
Just started studying C++.

1. Reading a book "You can Program in C++" by Francis Glassborow.
2. Installed Microsoft Visual Studio 2008 Express Edition (C++)
3. Started my first CLR Console Application and "Hello Word" program - ok
4. Second program with a custom header file / custom library - error

Error message as follows:
..\playpen2.cpp(3) : fatal error C1083: Cannot open include file: 'playpen.h': No such file or directory

How should I assign the path or what went wrong?
Oct 11, 2008 at 6:13am
I remember having that same problem. That is because "playpen.h" is a custom header file Francis Glassborow provided. Make sure you copy those working file into VS header file directory. And include the file as "playpen.h" There is somewhere in the project property where you can link the whole directory...I don't know where in VS though. :( gl.
Oct 11, 2008 at 1:25pm
To add a directory to the list of default include directories on VC++, you should go to
Tools > Options > Projects and Solutions > VC++ Directories
Select "Include files" on the combo box under "Show directories for:"
And then you will be able to add directories to look for when typing #include <something.h>
Oct 11, 2008 at 4:07pm
Ok, thank you so much! It was not too obvious for the first time use :-)

Another problem:
Line 44 in the "fgw_text.h" -file
if(c == EOF or c == '\n')break;
will cause an error while compiling:
error C2146: syntax error : missing ')' before identifier 'or'

After dividing the line to two separate lines
if(c == EOF) break;
if(c == '\n') break;
it works but there are several more complex lines with the same problem.

Any thoughs about that? Has syntax changed or what is that?
Oct 11, 2008 at 4:24pm
Try to replace or with ||
In C++ keywords as and, or and xor are not literal but they are &&, || and ^
resulting :
 
if(c == EOF || c == '\n')break;
Last edited on Oct 11, 2008 at 4:25pm
Oct 11, 2008 at 7:23pm
Thanks again! Getting closer to run playpen ...

This is just a reference code from a book, I think it should run without too much trouble.

This time following message ...


------ Build started: Project: Playpen3, Configuration: Debug Win32 ------
Compiling...
playpen3.cpp
Linking...
playpen3.obj : error LNK2028: unresolved token (0A000307) "public: __thiscall studentgraphics::playpen::playpen(class studentgraphics::hue)" (??0playpen@studentgraphics@@$$FQAE@Vhue@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
playpen3.obj : error LNK2028: unresolved token (0A000308) "public: __thiscall studentgraphics::playpen::~playpen(void)" (??1playpen@studentgraphics@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
playpen3.obj : error LNK2019: unresolved external symbol "public: __thiscall studentgraphics::playpen::~playpen(void)" (??1playpen@studentgraphics@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
playpen3.obj : error LNK2019: unresolved external symbol "public: __thiscall studentgraphics::playpen::playpen(class studentgraphics::hue)" (??0playpen@studentgraphics@@$$FQAE@Vhue@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
C:\Documents and Settings\Tapani\Omat tiedostot\Visual Studio 2008\Projects\Playpen3\Debug\Playpen3.exe : fatal error LNK1120: 4 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Tapani\Omat tiedostot\Visual Studio 2008\Projects\Playpen3\Playpen3\Debug\BuildLog.htm"
Playpen3 - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Oct 11, 2008 at 9:37pm
I usually get Linker errors when I use a non inplemented function
eg:
1
2
3
4
5
6
int MyFunction();

int main()
{
    return MyFunction();
}


If you try to compile this, you will get :
LNK2019: unresolved external symbol "int __cdecl MyFunction(void)" (?MyFunction@@YAHXZ) referenced in function _main


Try to check out if you have functions with missing body.
Last edited on Oct 11, 2008 at 9:38pm
Oct 15, 2008 at 8:13pm
Well, this is strange to me. Have not solved this case yet.

The code is simple:

// Playpen3.cpp : main project file.

#include "playpen.h"
#include <iostream>

int main()
{
fgw::playpen blank;
std::cout << "Press 'ENTER' key";
std::cin.get();
}

Library files can be found here (Windows Tutorial (zip)):
http://www.wiley.com:80/legacy/wileychi/glassborowc++/material.html

Libraries fgw;gdi32 should be added for the linker.
Library files path should be added for the compiler.

This library program should open a graphics window for the C++ program.

I try to continue solving this but maybe somebody have already solved this kind of problem?
Topic archived. No new replies allowed.