-1

I am have two projects that compile fine on their own.

One project, includes a reference to the other.

I am using Visual Studio 2012. One project is a VS2010 project and the the other was created with VS2012. Unsure if that is relevant.

Anyway. I get this type of error, when i include "RTSPTestServer"

I'll post the code if that is important here, but i believe this is some sort of configuration issue.

Both projects are C++ Win32 console apps. One has an RTSP class, the other wants to use that class. Both projects compile fine on their own in C++.

1 Import RTSP into VisionBase solution which contains VisionBase project. 2 Add additional include directories to VisionBase project. 3 Use RTSP class, complete with Intellisense in VisionBase. 4 Build solution.

At this stage i get the error.

Error 380 error C2011: 'netent' : 'struct' type redefinition C:\Program Files (x86)\Windows Kits\8.0\Include\um\Winsock2.h 238 1 VisionBase

I am using WinSock.h and WinSock2.h

Although i've searched google i can't find why i am getting redefinition errors. Both projects do have winsock as part of their respective standard external libraries. However, this is only referenced inside of the RTSP project. I only get an error when i try to import RTSP. Please help, read so much on this my head is in a spin.

WebSight
  • 640
  • 2
  • 12
  • 27

2 Answers2

1

The order of #include's matters a lot in WinSock programming (I believe this is one of FAQ.) See the discussion here:

Community
  • 1
  • 1
nodakai
  • 7,773
  • 3
  • 30
  • 60
0

A redefinition error means that this sort of thing is happening:

struct netent{...};
...
struct netent{...}; // error C2011

This can happen when that struct is declared in a header with no include guards that's included twice, or if you're using multiple versions of the same library, or a myriad of other possibilities.

I'm not familiar with recent VS compilers, but if they're like every other modern compiler then the error message will tell you both places where it sees the multiple definitions, and the chain of includes that get it there. That should help you narrow down the issue.

BTW, the term "import" has no meaning in C++. You likely mean "include" which serves the same purpose as "import" in other languages, but it's implemented in a way that acts significantly differently when things go wrong. #include <header.h> will in effect copy/paste the contents of header.h.

Adam
  • 16,808
  • 7
  • 52
  • 98