• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Migi0027

C++ Including causes redifinition

13 posts in this topic

Hi guys, im currently having a problem with including:

Small diagram:

Editor.h
|
|
System.h
/ | \
/ | \
/ | \
EDIT: The spaces wont apply!!! So the diagram is bugged.. But the point is that Editor.h includes System.h which includes loads of different headers...

The system.h includes loads of different headers. All of theese headers have including guards, but still, i get redifinition errors in my Editor.obj(when debugging) which came from the system.h

E.g.

In system.h:
class SHADER
{
public:bool CompileFromShader; //If you put this value to false, you are as well fucking up this...
public:LPCSTR ShaderFileName;
};

And then it says, that this has been redefined in the Editor.obj (Editor.h)

Please help me.

Best Regards
Miguel Petersen Edited by Migi0027
0

Share this post


Link to post
Share on other sites
Just to be perfectly clear, both editor.h and system.h have include guards? You said all the others do.

If your on Visual Studio you can use the [source lang="cpp]# pragma once[/source] directive instead of:[source lang="cpp]
# ifndef __INCLUDE_H_
# define __INCLUDE_H_ 1

/*
** include.h - a collection of useful headers
*/

# endif /* __INCLUDE_H_ */

[/source]I tend not to like the first because it's not really a standard directive.

Failing that, I've found that I get compiling errors if I don't leave a blank line at the end of my files. I'm not sure of the technical reason why.

I hope this helps.

Also, you haven't accidently copied the class definition into one of the source files have you? It seems stupid I was adding to my engine the other day and I just started in a source file before I moved parts to a header. Edited by BinaryPhysics
1

Share this post


Link to post
Share on other sites
Please post the actual error you are receiving. The error contains important information that will help pinpoint the cause of the problem.
1

Share this post


Link to post
Share on other sites
Errors as requested:

1>main.obj : error LNK2005: "void __cdecl EnableAA(struct ID3D11Device *)" (?EnableAA@@YAXPAUID3D11Device@@@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl CalcCamera(float,float)" (?CalcCamera@@YAXMM@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl RenderFrame(void)" (?RenderFrame@@YAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl CleanD3D(void)" (?CleanD3D@@YAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitGraphics(void)" (?InitGraphics@@YAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitPipeline(void)" (?InitPipeline@@YAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl Cube3D::LoopRender(void)" (?LoopRender@Cube3D@@YAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@YAXPAUHWND__@@@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11DepthStencilView * zbuffer" (?zbuffer@@3PAUID3D11DepthStencilView@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11RenderTargetView * backbuffer" (?backbuffer@@3PAUID3D11RenderTargetView@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct IDXGISwapChain * swapchain" (?swapchain@@3PAUIDXGISwapChain@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11Device * dev" (?dev@@3PAUID3D11Device@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11DeviceContext * devcon" (?devcon@@3PAUID3D11DeviceContext@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11InputLayout * pLayout" (?pLayout@@3PAUID3D11InputLayout@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11Buffer * pCBuffer" (?pCBuffer@@3PAUID3D11Buffer@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11VertexShader * pVS" (?pVS@@3PAUID3D11VertexShader@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct ID3D11PixelShader * pPS" (?pPS@@3PAUID3D11PixelShader@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "unsigned long * CubeIndices" (?CubeIndices@@3PAKA) already defined in Editor.obj
1>main.obj : error LNK2005: "bool UseAA" (?UseAA@@3_NA) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl EnableAA(struct ID3D11Device *)" (?EnableAA@@$$FYAXPAUID3D11Device@@@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl CalcCamera(float,float)" (?CalcCamera@@$$FYAXMM@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl RenderFrame(void)" (?RenderFrame@@$$FYAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl CleanD3D(void)" (?CleanD3D@@$$FYAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitGraphics(void)" (?InitGraphics@@$$FYAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitPipeline(void)" (?InitPipeline@@$$FYAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl Cube3D::LoopRender(void)" (?LoopRender@Cube3D@@$$FYAXXZ) already defined in Editor.obj
1>main.obj : error LNK2005: "void __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@$$FYAXPAUHWND__@@@Z) already defined in Editor.obj
1>main.obj : error LNK2005: "struct D3DXMATRIX matFinal" (?matFinal@@3UD3DXMATRIX@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct D3DXMATRIX matProjection" (?matProjection@@3UD3DXMATRIX@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct D3DXMATRIX matRotate" (?matRotate@@3UD3DXMATRIX@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct D3DXMATRIX matView" (?matView@@3UD3DXMATRIX@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct CUBE * CubeVertices" (?CubeVertices@@3PAUCUBE@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct CBUFFER cBuffer" (?cBuffer@@3UCBUFFER@@A) already defined in Editor.obj
1>main.obj : error LNK2005: "struct D3DXMATRIX matPosition" (?matPosition@@3UD3DXMATRIX@@A) already defined in Editor.obj
1>C:\Users\Utilizador\Documents\Visual Studio 11\Projects\Cube3D\Debug\CuboidEngine.exe : fatal error LNK1169: one or more multiply defined symbols found
0

Share this post


Link to post
Share on other sites
Are you sure you're not accidentally including a .cpp file instead of an .h file? The errors indicate that the linker found multiple copies of certain [i]functions and variables[/i].
0

Share this post


Link to post
Share on other sites
Also check any non-template, non-member inline functions are labeled with the inline keyword.
1

Share this post


Link to post
Share on other sites
Maybe i solved it, but now it cannot find my entry point. I have defined it in the properties->Linker->All Options->Entry main.cpp, but it wont accept it, it gives me just one external error now:

Error 31 error LNK2001: unresolved external symbol _main.cpp
0

Share this post


Link to post
Share on other sites
The entry point is a function name, not a file name. You should not manually set the entry point unless you are 100% sure of what you are doing. Have you set the correct subsystem? Do you have an implementation of main() or WinMain()? They must be free functions and not class members. Perhaps you have made a minor error in the signature?
2

Share this post


Link to post
Share on other sites
I removed my entry point, but now this comes up:
Error 31 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
0

Share this post


Link to post
Share on other sites
If you're making a windows program you need to have a [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx"]WinMain function[/url] rather than a main function.
0

Share this post


Link to post
Share on other sites
Manually defined your entry point means what? Did you create the necessary function, or did you set the "entry point" in your linker settings?

If the latter, please be aware this is very advanced functionality and almost certainly not what you should be doing. [url="http://msdn.microsoft.com/en-us/library/f9t8842e(v=vs.80).aspx"]For example[/url]:
[quote]
The /ENTRY option specifies an entry point function as the starting address for an .exe file or DLL.

The function must be defined with the __stdcall calling convention. The parameters and return value must be defined as documented in the Win32 API for WinMain (for an .exe file) or DllEntryPoint (for a DLL). [b]It is recommended that you let the linker set the entry point so that the C run-time library is initialized correctly, and C++ constructors for static objects are executed.[/b]

By default, the starting address is a function name from the C run-time library. The linker selects it according to the attributes of the program, as shown in the following table.
[/quote]
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0