Răsfoiți Sursa

1.linux上编译enet OK
2.linux上UNetTest要调用libENet.so,需要设置LD_LIBRARY_PATH以便查找libENet.so
3.UNetTest仍然crash

tanghai 11 ani în urmă
părinte
comite
e5812f5cde

+ 17 - 4
CSharp-Mono/CSharp-Mono.userprefs

@@ -1,9 +1,22 @@
 <Properties StartupItem="Platform\Common\Common.csproj">
 <Properties StartupItem="Platform\Common\Common.csproj">
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
-  <MonoDevelop.Ide.Workbench ActiveDocument="d:\Source\Egametang\CSharp\Platform\TNetTest\TcpListenerTest.cs">
-    <Files>
-      <File FileName="d:\Source\Egametang\CSharp\Platform\TNetTest\TcpListenerTest.cs" Line="4" Column="4" />
-    </Files>
+  <MonoDevelop.Ide.Workbench>
+    <Pads>
+      <Pad Id="MonoDevelop.NUnit.TestPad">
+        <State expanded="True">
+          <Node name="Platform" expanded="True">
+            <Node name="TNetTest" expanded="True">
+              <Node name="TNetTest" expanded="True">
+                <Node name="TServiceTest" selected="True" />
+              </Node>
+            </Node>
+            <Node name="UNetTest" expanded="True">
+              <Node name="UNetTest" expanded="True" />
+            </Node>
+          </Node>
+        </State>
+      </Pad>
+    </Pads>
   </MonoDevelop.Ide.Workbench>
   </MonoDevelop.Ide.Workbench>
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
     <BreakpointStore />
     <BreakpointStore />

+ 18 - 0
CSharp/CMakeLists.txt

@@ -0,0 +1,18 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4)
+
+SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
+SET(CMAKE_USE_RELATIVE_PATHS ON)
+IF(NOT CMAKE_BUILD_TYPE)
+	SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF()
+
+PROJECT(CSharp)
+
+# 设置头文件查找路径
+INCLUDE_DIRECTORIES(Platform)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/Platform)
+
+ADD_DEFINITIONS(-DHAS_SOCKLEN_T)
+
+# 子目录
+ADD_SUBDIRECTORY(Platform/ENet)

+ 17 - 17
CSharp/CSharp.sln

@@ -44,12 +44,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{AAD111
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNet", "Platform\UNet\UNet.csproj", "{D0B4CFAC-A368-4742-9863-68776CFA9938}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNet", "Platform\UNet\UNet.csproj", "{D0B4CFAC-A368-4742-9863-68776CFA9938}"
 EndProject
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENet", "Platform\ENet\ENet.vcxproj", "{C9992B7C-313E-4C9F-A954-640D01EDFB58}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNetTest", "Platform\UNetTest\UNetTest.csproj", "{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNetTest", "Platform\UNetTest\UNetTest.csproj", "{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProfileExe", "Platform\ProfileExe\ProfileExe.csproj", "{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProfileExe", "Platform\ProfileExe\ProfileExe.csproj", "{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}"
 EndProject
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENet", "Platform\ENet\ENet.vcxproj", "{C9992B7C-313E-4C9F-A954-640D01EDFB58}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -184,20 +184,6 @@ Global
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|Win32.ActiveCfg = Release|Any CPU
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|Win32.ActiveCfg = Release|Any CPU
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|x86.ActiveCfg = Release|Any CPU
 		{D0B4CFAC-A368-4742-9863-68776CFA9938}.Release|x86.ActiveCfg = Release|Any CPU
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Any CPU.ActiveCfg = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Mixed Platforms.Build.0 = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Win32.ActiveCfg = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Win32.Build.0 = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.ActiveCfg = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.Build.0 = Debug|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Any CPU.ActiveCfg = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Mixed Platforms.ActiveCfg = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Mixed Platforms.Build.0 = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Win32.ActiveCfg = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Win32.Build.0 = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.ActiveCfg = Release|Win32
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.Build.0 = Release|Win32
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -222,6 +208,20 @@ Global
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|Win32.ActiveCfg = Release|Any CPU
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|Win32.ActiveCfg = Release|Any CPU
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|x86.ActiveCfg = Release|Any CPU
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Release|x86.ActiveCfg = Release|Any CPU
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Win32.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Any CPU.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Win32.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Win32.Build.0 = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE
@@ -238,8 +238,8 @@ Global
 		{6CD185D1-08E0-4729-A999-2D5B57BA8193} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
 		{6CD185D1-08E0-4729-A999-2D5B57BA8193} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
 		{93FB20CF-827A-4CED-A273-90117EB7192F} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
 		{93FB20CF-827A-4CED-A273-90117EB7192F} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
 		{D0B4CFAC-A368-4742-9863-68776CFA9938} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{D0B4CFAC-A368-4742-9863-68776CFA9938} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
-		{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{901A8E5C-C4C6-4C3C-8E18-068D75119F5D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{CBA52DC8-1C80-4A79-9AC5-73514EBBD749} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 	EndGlobalSection
 	EndGlobalSection
 EndGlobal
 EndGlobal

+ 15 - 0
CSharp/Platform/ENet/CMakeLists.txt

@@ -0,0 +1,15 @@
+INCLUDE_DIRECTORIES(.)
+
+FILE(GLOB Header "enet/*.h")
+FILE(GLOB CCer "*.c")
+
+SET(ENetSrc 
+	${Header}
+	${CCer}
+)
+
+ADD_LIBRARY(ENet SHARED ${ENetSrc})
+
+set_target_properties(ENet PROPERTIES 
+  LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/"
+)

+ 18 - 18
CSharp/Platform/ENet/ENet.vcxproj

@@ -104,26 +104,26 @@
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
-    <ClCompile Include="callbacks.cc" />
-    <ClCompile Include="compress.cc" />
-    <ClCompile Include="host.cc" />
-    <ClCompile Include="list.cc" />
-    <ClCompile Include="packet.cc" />
-    <ClCompile Include="peer.cc" />
-    <ClCompile Include="protocol.cc" />
-    <ClCompile Include="unix.cc" />
-    <ClCompile Include="win32.cc" />
+    <ClCompile Include="callbacks.c" />
+    <ClCompile Include="compress.c" />
+    <ClCompile Include="host.c" />
+    <ClCompile Include="list.c" />
+    <ClCompile Include="packet.c" />
+    <ClCompile Include="peer.c" />
+    <ClCompile Include="protocol.c" />
+    <ClCompile Include="unix.c" />
+    <ClCompile Include="win32.c" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <ClInclude Include="callbacks.h" />
-    <ClInclude Include="enet.h" />
-    <ClInclude Include="list.h" />
-    <ClInclude Include="protocol.h" />
-    <ClInclude Include="time.h" />
-    <ClInclude Include="types.h" />
-    <ClInclude Include="unix.h" />
-    <ClInclude Include="utility.h" />
-    <ClInclude Include="win32.h" />
+    <ClInclude Include="enet\callbacks.h" />
+    <ClInclude Include="enet\enet.h" />
+    <ClInclude Include="enet\list.h" />
+    <ClInclude Include="enet\protocol.h" />
+    <ClInclude Include="enet\time.h" />
+    <ClInclude Include="enet\types.h" />
+    <ClInclude Include="enet\unix.h" />
+    <ClInclude Include="enet\utility.h" />
+    <ClInclude Include="enet\win32.h" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   <ImportGroup Label="ExtensionTargets">

+ 48 - 0
CSharp/Platform/ENet/ENet.vcxproj.filters

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <ClCompile Include="callbacks.c" />
+    <ClCompile Include="compress.c" />
+    <ClCompile Include="host.c" />
+    <ClCompile Include="list.c" />
+    <ClCompile Include="packet.c" />
+    <ClCompile Include="peer.c" />
+    <ClCompile Include="protocol.c" />
+    <ClCompile Include="unix.c" />
+    <ClCompile Include="win32.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <Filter Include="enet">
+      <UniqueIdentifier>{5b0e5c61-d179-4c41-a760-6154cf2db017}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="enet\callbacks.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\enet.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\list.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\protocol.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\time.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\types.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\unix.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\utility.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+    <ClInclude Include="enet\win32.h">
+      <Filter>enet</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>

+ 0 - 0
CSharp/Platform/ENet/callbacks.cc → CSharp/Platform/ENet/callbacks.c


+ 0 - 0
CSharp/Platform/ENet/compress.cc → CSharp/Platform/ENet/compress.c


+ 0 - 0
CSharp/Platform/ENet/callbacks.h → CSharp/Platform/ENet/enet/callbacks.h


+ 0 - 0
CSharp/Platform/ENet/enet.h → CSharp/Platform/ENet/enet/enet.h


+ 0 - 0
CSharp/Platform/ENet/list.h → CSharp/Platform/ENet/enet/list.h


+ 0 - 0
CSharp/Platform/ENet/protocol.h → CSharp/Platform/ENet/enet/protocol.h


+ 0 - 0
CSharp/Platform/ENet/time.h → CSharp/Platform/ENet/enet/time.h


+ 0 - 0
CSharp/Platform/ENet/types.h → CSharp/Platform/ENet/enet/types.h


+ 0 - 0
CSharp/Platform/ENet/unix.h → CSharp/Platform/ENet/enet/unix.h


+ 0 - 0
CSharp/Platform/ENet/utility.h → CSharp/Platform/ENet/enet/utility.h


+ 0 - 0
CSharp/Platform/ENet/win32.h → CSharp/Platform/ENet/enet/win32.h


+ 0 - 0
CSharp/Platform/ENet/host.cc → CSharp/Platform/ENet/host.c


+ 0 - 0
CSharp/Platform/ENet/list.cc → CSharp/Platform/ENet/list.c


+ 0 - 0
CSharp/Platform/ENet/packet.cc → CSharp/Platform/ENet/packet.c


+ 0 - 0
CSharp/Platform/ENet/peer.cc → CSharp/Platform/ENet/peer.c


+ 0 - 0
CSharp/Platform/ENet/protocol.cc → CSharp/Platform/ENet/protocol.c


+ 0 - 0
CSharp/Platform/ENet/unix.cc → CSharp/Platform/ENet/unix.c


+ 0 - 0
CSharp/Platform/ENet/win32.cc → CSharp/Platform/ENet/win32.c


+ 3 - 5
CSharp/Platform/UNet/NativeMethods.cs

@@ -7,7 +7,7 @@ namespace UNet
 {
 {
 	public static class NativeMethods
 	public static class NativeMethods
 	{
 	{
-		private const string LIB = "ENet.dll";
+		private const string LIB = "ENet";
 
 
 		public const int ENET_PEER_PACKET_THROTTLE_SCALE = 32;
 		public const int ENET_PEER_PACKET_THROTTLE_SCALE = 32;
 		public const int ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2;
 		public const int ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2;
@@ -20,12 +20,10 @@ namespace UNet
 		public const uint ENET_HOST_ANY = 0;
 		public const uint ENET_HOST_ANY = 0;
 		public const uint ENET_HOST_BROADCAST = 0xffffffff;
 		public const uint ENET_HOST_BROADCAST = 0xffffffff;
 
 
-		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_address_set_host")
-		]
+		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_address_set_host")]
 		internal static extern int EnetAddressSetHost(ref ENetAddress address, string hostName);
 		internal static extern int EnetAddressSetHost(ref ENetAddress address, string hostName);
 
 
-		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_address_get_host")
-		]
+		[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_address_get_host")]
 		internal static extern int EnetAddressGetHost(
 		internal static extern int EnetAddressGetHost(
 				ref ENetAddress address, StringBuilder hostName, uint nameLength);
 				ref ENetAddress address, StringBuilder hostName, uint nameLength);