Hello everyone!
I'm using Dev version 4.9.9.2 on XP, and I'm having trouble using GDI+.
This is my first time using graphics on C++, so I'm a little confused.
C:\ctestproject\gdiplus\myfirst.cpp:2: error: expected namespace-name before ';' token
C:\ctestproject\gdiplus\myfirst.cpp:2: error: <type error>' is not a namespace
C:\ctestproject\gdiplus\myfirst.cpp:6: error:BOOL' does not name a type
C:\ctestproject\gdiplus\myfirst.cpp:22: error: `CGdiplustestDlg' has not been declared
C:\ctestproject\gdiplus\myfirst.cpp: In function void OnPaint()':
C:\ctestproject\gdiplus\myfirst.cpp:24: error:CPaintDC' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:24: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\ctestproject\gdiplus\myfirst.cpp:24: error: expected ;' before "dc"
C:\ctestproject\gdiplus\myfirst.cpp:25: error:Graphics' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:25: error: expected `;' before "graphics"
C:\ctestproject\gdiplus\myfirst.cpp:27: error: Pen' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:27: error: expected;' before "pen1"
C:\ctestproject\gdiplus\myfirst.cpp:28: error: graphics' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:28: error:pen1' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:32: error: expected `;' before "pen1"
C:\ctestproject\gdiplus\myfirst.cpp:36: error: SmoothingModeAntiAlias' undeclared (first use this function)
C:\ctestproject\gdiplus\myfirst.cpp:39: error: expected;' before "pen1"
Execution terminated
///////////////////
I tried putting gdiplus.dll in all sorts of places, but that didn't work. I also changed it to gdiplus.h, but I did that just by renaming it, so I don't know if that matters.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your problem all starts with the first error message, which has nothing to do with dll's
C:\ctestproject\gdiplus\myfirst.cpp:1:22: Gdiplus.h: No such file or directory
This says that the compiler does know where the header file Gdiplus.h is.
Now, there may be other issues.
(1) I don't know if you can use the DirectX SDK out of the box with the GCC compiler. It was built for Microsoft's compiler.
(2) You have spaces in paths all over the place. That can cause you major headaches.
I notice also you are not linking any libraries. Do you know what that means/how to do it?
I recommend that if you are just starting with graphics, you check out the thread titled "Please Read Before Posting a Question" - there is a section in there on getting started with Glut - which is OpenGL - an open graphics tool.
You will also want to check the section on the compile log, including headers and linking libraries.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I put in all the library and include files into C:\Dev-Cpp\include and C:\Dev-Cpp\lib, but it still won't work. I also tried linking a library, but I don't know if I did it right.
/////////////
COMPILE LOG:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\ctestproject\gdiplus\myfirst.cpp" -o "C:\ctestproject\gdiplus\myfirst.exe" -g3 -I"lib\gcc\mingw32\3.4.2\include" -I"include\c++\3.4.2\backward" -I"include\c++\3.4.2\mingw32" -I"include\c++\3.4.2" -I"include" -L"lib" -lgdiplus -g3
In file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:109,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusMem.h:40: error: `size_t' was not declared in this scope
In file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:112,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:25: error: declaration of operator new' as non-function
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:25: error: expected;' before '(' token
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:29: error: expected ;' before "void"
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:33: error: declaration ofoperator new []' as non-function
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:33: error: expected ;' before '(' token
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:37: error: expected;' before '}' token
In file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:115,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusEnums.h:29: error: UINT' does not name a type
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusEnums.h:30: error:UINT' does not name a type
/////////////
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh yeah! I had to cut the compile log short because it was about 2000 lines long, but basically it does the same thing for every Gdiplus file with these as the last few lines:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:50: note: Gdiplus::Color::Color()
C:\ctestproject\gdiplus\myfirst.cpp:33: error: 'class Gdiplus::Graphics' has no member named 'DrawLine'
C:\ctestproject\gdiplus\myfirst.cpp:36: error: 'class Gdiplus::Graphics' has no member named 'SetSmoothingMode'
C:\ctestproject\gdiplus\myfirst.cpp:39: error: no matching function for call to `Gdiplus::Color::Color(int, int, int)'
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:46: note: candidates are: Gdiplus::Color::Color(const Gdiplus::Color&)
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:50: note: Gdiplus::Color::Color()
C:\ctestproject\gdiplus\myfirst.cpp:40: error: 'class Gdiplus::Graphics' has no member named 'DrawLine'
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
and yes, as Wayne stated already, there is a very good chance that the original directx libs doesn't work along with dev-cpp and the same goes for the directx-headers.
Since I don't have a gdiplus lib, nor any gdiplus-.h files even with the dx9 devpack installed you seem to be out of luck.
a possible solution for you would be to grab the the freely available vctoolkit2003 from ms http://msdn.microsoft.com/visualc/vctoolkit2003/
and use it along with the Code::Blocks compiler, which is supposed to support it (vctoolkit is a command-line compiler only and you can use Code::Blocks as an IDE for it) http://www.codeblocks.org/
HTH
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did you try to compile it with the toolkit I mentioned? Codeblocks itself uses the same (maybe quite a newer version) of gcc just like dev-cpp, so there shouldn't be much difference if you don't use another compiler along with it.
I googled for your problem, since I didn't know the header.
To get it to compile with dev-c++ you would need to rewrite the enums in the header into standard compliant format. I think that isn't worth the work at all so I don't even try to explain it here. If you really want to do it nethertheless you can find an example here:
www.softgames.de/forum/frage116557.html
^last posting
I would recommend to use an ms compiler in any case, or just give up this 'crap' completely ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone!
I'm using Dev version 4.9.9.2 on XP, and I'm having trouble using GDI+.
This is my first time using graphics on C++, so I'm a little confused.
////////////
CODE:
////////////
include <Gdiplus.h>
using namespace Gdiplus;
pragma comment(lib, "gdiplus.lib")
BOOL CGdiplustestApp::InitInstance()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
}
void CGdiplustestDlg::OnPaint()
{
CPaintDC dc(this);
Graphics graphics(dc);
{
Pen pen1(Color(255, 255, 255), 400);
graphics.DrawLine(&pen1, 200, 0, 200, 400);
}
}
///////////////
COMPILE LOG:
///////////////
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\ctestproject\gdiplus\myfirst.cpp" -o "C:\ctestproject\gdiplus\myfirst.exe" -g3 -I"lib\gcc\mingw32\3.4.2\include" -I"include\c++\3.4.2\backward" -I"include\c++\3.4.2\mingw32" -I"include\c++\3.4.2" -I"include" -I"C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include" -L"lib" -g3
C:\ctestproject\gdiplus\myfirst.cpp:1:22: Gdiplus.h: No such file or directory
C:\ctestproject\gdiplus\myfirst.cpp:2: error: expected namespace-name before ';' token
C:\ctestproject\gdiplus\myfirst.cpp:2: error:
<type error>' is not a namespace C:\ctestproject\gdiplus\myfirst.cpp:6: error:
BOOL' does not name a typeC:\ctestproject\gdiplus\myfirst.cpp:22: error: `CGdiplustestDlg' has not been declared
C:\ctestproject\gdiplus\myfirst.cpp: In function
void OnPaint()': C:\ctestproject\gdiplus\myfirst.cpp:24: error:
CPaintDC' undeclared (first use this function)C:\ctestproject\gdiplus\myfirst.cpp:24: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\ctestproject\gdiplus\myfirst.cpp:24: error: expected
;' before "dc" C:\ctestproject\gdiplus\myfirst.cpp:25: error:
Graphics' undeclared (first use this function)C:\ctestproject\gdiplus\myfirst.cpp:25: error: expected `;' before "graphics"
C:\ctestproject\gdiplus\myfirst.cpp:27: error:
Pen' undeclared (first use this function) C:\ctestproject\gdiplus\myfirst.cpp:27: error: expected
;' before "pen1"C:\ctestproject\gdiplus\myfirst.cpp:28: error:
graphics' undeclared (first use this function) C:\ctestproject\gdiplus\myfirst.cpp:28: error:
pen1' undeclared (first use this function)C:\ctestproject\gdiplus\myfirst.cpp:32: error: expected `;' before "pen1"
C:\ctestproject\gdiplus\myfirst.cpp:36: error:
SmoothingModeAntiAlias' undeclared (first use this function) C:\ctestproject\gdiplus\myfirst.cpp:39: error: expected
;' before "pen1"Execution terminated
///////////////////
I tried putting gdiplus.dll in all sorts of places, but that didn't work. I also changed it to gdiplus.h, but I did that just by renaming it, so I don't know if that matters.
yeah I tried that, but I'm just gonna give up and use OpenGL. Thanks anyway!
Take the time to look into the Glut stuff I pointed you to.
Remember, if you have problems (and I don't think you will) - remember to tell us exactly what you did, including your basic 3
Wayne
Your problem all starts with the first error message, which has nothing to do with dll's
C:\ctestproject\gdiplus\myfirst.cpp:1:22: Gdiplus.h: No such file or directory
This says that the compiler does know where the header file Gdiplus.h is.
Now, there may be other issues.
(1) I don't know if you can use the DirectX SDK out of the box with the GCC compiler. It was built for Microsoft's compiler.
(2) You have spaces in paths all over the place. That can cause you major headaches.
I notice also you are not linking any libraries. Do you know what that means/how to do it?
I recommend that if you are just starting with graphics, you check out the thread titled "Please Read Before Posting a Question" - there is a section in there on getting started with Glut - which is OpenGL - an open graphics tool.
You will also want to check the section on the compile log, including headers and linking libraries.
Wayne
I put in all the library and include files into C:\Dev-Cpp\include and C:\Dev-Cpp\lib, but it still won't work. I also tried linking a library, but I don't know if I did it right.
/////////////
COMPILE LOG:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\ctestproject\gdiplus\myfirst.cpp" -o "C:\ctestproject\gdiplus\myfirst.exe" -g3 -I"lib\gcc\mingw32\3.4.2\include" -I"include\c++\3.4.2\backward" -I"include\c++\3.4.2\mingw32" -I"include\c++\3.4.2" -I"include" -L"lib" -lgdiplus -g3
In file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:109,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusMem.h:40: error: `size_t' was not declared in this scope
In file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:112,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:25: error: declaration of
operator new' as non-function C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:25: error: expected
;' before '(' tokenC:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:29: error: expected
;' before "void" C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:33: error: declaration of
operator new []' as non-functionC:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:33: error: expected
;' before '(' token C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusBase.h:37: error: expected
;' before '}' tokenIn file included from C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/Gdiplus.h:115,
from C:\ctestproject\gdiplus\myfirst.cpp:1:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusEnums.h:29: error:
UINT' does not name a type C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusEnums.h:30: error:
UINT' does not name a type/////////////
Oh yeah! I had to cut the compile log short because it was about 2000 lines long, but basically it does the same thing for every Gdiplus file with these as the last few lines:
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:50: note: Gdiplus::Color::Color()
C:\ctestproject\gdiplus\myfirst.cpp:33: error: 'class Gdiplus::Graphics' has no member named 'DrawLine'
C:\ctestproject\gdiplus\myfirst.cpp:36: error: 'class Gdiplus::Graphics' has no member named 'SetSmoothingMode'
C:\ctestproject\gdiplus\myfirst.cpp:39: error: no matching function for call to `Gdiplus::Color::Color(int, int, int)'
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:46: note: candidates are: Gdiplus::Color::Color(const Gdiplus::Color&)
C:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/GdiplusColor.h:50: note: Gdiplus::Color::Color()
C:\ctestproject\gdiplus\myfirst.cpp:40: error: 'class Gdiplus::Graphics' has no member named 'DrawLine'
Execution terminated
`UINT' does not name a type
seems like you missed to #include <windows.h>
??
and yes, as Wayne stated already, there is a very good chance that the original directx libs doesn't work along with dev-cpp and the same goes for the directx-headers.
Since I don't have a gdiplus lib, nor any gdiplus-.h files even with the dx9 devpack installed you seem to be out of luck.
a possible solution for you would be to grab the the freely available vctoolkit2003 from ms http://msdn.microsoft.com/visualc/vctoolkit2003/
and use it along with the Code::Blocks compiler, which is supposed to support it (vctoolkit is a command-line compiler only and you can use Code::Blocks as an IDE for it) http://www.codeblocks.org/
HTH
there are still a few errors after using Code::Blocks, but they are all related to GdiPlusEnums.h.
After Googling gdiplusenums, I found a related topic from this forum at http://www.gamedev.net/community/forums/topic.asp?topic_id=225589
but i don't know what he means by taking out the forward declarations. Does anyone know what I need to do?
Did you try to compile it with the toolkit I mentioned? Codeblocks itself uses the same (maybe quite a newer version) of gcc just like dev-cpp, so there shouldn't be much difference if you don't use another compiler along with it.
I googled for your problem, since I didn't know the header.
To get it to compile with dev-c++ you would need to rewrite the enums in the header into standard compliant format. I think that isn't worth the work at all so I don't even try to explain it here. If you really want to do it nethertheless you can find an example here:
www.softgames.de/forum/frage116557.html
^last posting
I would recommend to use an ms compiler in any case, or just give up this 'crap' completely ;-)